How to show only specific tag in wordpress loop

Here are two alternative for you based on your actual query. If you’re querying $projects->have_posts() on WP default blog (Post) you can use query like $projects = new WP_Query( array( ‘tag__in’ => array( 52, 53 ) ) ); Another is if you’re querying on Custom Post Type you can use following query to get posts … Read more

Why does the first loop take arguments from the second loop?

Please try below code : <?php get_header(); ?> <main role=”main”> <section class=”container”> <div class=”row”> <div class=”col-lg-8″> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <h1 class=”text-center><?php the_title(); ?></h1> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?> <div class=”row”> <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args … Read more

Having issue with WordPress loop

As per the documentation I am doing everything right, but on the frontend, it is not showing all of the posts, Any idea what I am doing wrong? The documentation does not say to use a custom page template for displaying the blog archive. As shown in the template hierarchy the template for your blog … Read more

How to create a custom loop ordered by Categories on a Page Template?

Not sure if this is exactly what you’re asking, but it sounds like you’re looking for nested loops. This will list the most recent 5 posts in every category on your site: foreach ( get_terms(‘category’) as $category ) { echo ‘<h2>’.$category->name.'</h2>’; echo ‘<ul>’; foreach ( get_posts( ‘cat=”.$category->term_id ) as $post ) { setup_postdata( $post ); … Read more