WordPress simple tips, advance functionability.

I will UPDATE this post every time i discover a new one!

  1. Count system for post in wordpress

    This will create automatically a new Custom Field for your post count, called “count_page_hits”. If you want to know how to display them visit: http://codex.wordpress.org/Custom_Fields

    function count_page_hits() {
     if(is_single()) {
       global $post;
       $count = get_post_meta($post->ID, 'count_page_hits', true);
       $newcount = $count + 1;
    
       update_post_meta($post->ID, 'count_page_hits', $newcount);
     }
    }
    add_action('wp_head', 'count_page_hits');

    Source: Bavotasan.com

About Diogo15

Web developer and Designer!

Comments are closed.