First post in loop displays twice

The else of the $change % 5 == 0 also runs when $change is a 1 and that is why the first post is displayed twice. You could fix it by changing <?php $change++ ?> <?php endif; ?> <?php if ( $change % 5 == 0 ) : ?> to <?php $change++ ?> <?php elseif … Read more

Pagination in category.php not functioning

if your aim is to restrict the category archive to your post_type ‘video’ and to 6 posts per page, do not edit category.php, rather use ‘pre_get_posts’ https://developer.wordpress.org/reference/hooks/pre_get_posts/ example code for your case: add_action( ‘pre_get_posts’, ‘category_post_type_video_custom’ ); function category_post_type_video_custom( $query ) { if ( ! is_admin() && $query->is_main_query() ) { // Not a query for an … Read more

I need to update the post query? [closed]

You should use tax_query. $args = [ ‘posts_per_page’ => 10, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’ ‘tax_query’ => array( array( ‘taxonomy’ => ‘state’, ‘field’ => ‘slug’, ‘terms’ => ‘minnesota’, // lowercase m ), ];

Alternative loop syntax error [closed]

Because you’re using semicolons when you should be using colons after the if and the while 🙂 query_posts( ‘year=2011’ ); if ( have_posts() ): while ( have_posts() ): the_post(); the_title(); endwhile; wp_reset_query(); endif; That works just fine.

While loop inside another while loop

I would create a custom query for each nested loop and loop on its post data. Similar to what is written about here. You will probably need to save the post global to a temporary variable so it can be set back ( setup_postdata() ) at the end of the nested look.

Tag custom loop show posts

It is not recommended to use query_posts. But this is not the problem, Problem is you are using PHP variable in single quotes. ‘tag=$tag’ Consider these examples: query_posts(‘tag=php’); //OR query_posts(“tag=$tag”); //$tag should output: php Using WP_query //Recommended $query = new WP_Query(array( ‘tag’ => ‘php’ )); Ref: WP_Query-Tag_Parameters | query_posts