<?php
$counter=1;
$counter_new=0;
$args = array('posts_per_page' =>-1,'orderby' => 'post_date','order' =>'DESC','post_type' => 'interview','post_status' => 'publish',
'suppress_filters' => true );query_posts( $args );while (have_posts($args)) : the_post();
if($counter < 8)
{
$counter++;
}
else
{
$counter_new++;
$counter=1;
}
endwhile;
?>
I saw someone else code to find the number of post, as record increase it is not efficient. What is the right way to do? It looks stupid now.
In case you use WPML wp_count_post() will not show correct count of posts for given language. Use this instead:
Take a look at the wp_count_posts() function.
For your example:
$published_posts will return the number of published posts in your ‘interview’ custom post type.
One of the other answers won’t work if you have WMPL and translations. The other one will work, but will be very inefficient.
With WPML, try this instead:
You’d use it like this: