• We are using the Avada-3.6.2 theme, We have updated some posts on this page http://www.privatevillasphuket.com/wp/guest-comments

    We need to display the posts using numbers like the below image We do not need to show the day of the month on the left hand side – just the month and year .

    http://www.privatevillasphuket.com/example.jpg

    We found some solution for this here is the code but it’s not working for us.
    URL OF THE CODE : http://www.hongkiat.com/blog/wordpress-tweaks-for-post-management

    5. Display an incrementing number on each post
    The tweak below will let you display an incrementing number on each post, and implementing it is pretty simple. First, paste the following function into your functions.php file:

    function updateNumbers() {
    global $wpdb;
    $querystr = "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ";
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    $counts = 0 ;
    if ($pageposts):
    foreach ($pageposts as $post):
    setup_postdata($post);
    $counts++;
    add_post_meta($post->ID, 'incr_number', $counts, true);
    update_post_meta($post->ID, 'incr_number', $counts);
    endforeach;
    endif;
    }
    add_action ( 'publish_post', 'updateNumbers' );
    add_action ( 'deleted_post', 'updateNumbers' );
    add_action ( 'edit_post', 'updateNumbers' );

    Once you’re done, you can display the post number with the following code. Note that it has to be used within the loop.

    <?php echo get_post_meta($post->ID,'incr_number',true); ?>

    Please let me know the solution about this issue.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Using Avada theme display the posts numbers’ is closed to new replies.