How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false

The simplest solution would be to query all posts using a -1 in place of the 12 in your ‘posts_per_page’ argument of your query. Then use a counter that ticks up if all of the above conditions equal true. $args = array( ‘post_type’ => $post_slug, ‘posts_per_page’ => -1, ‘paged’ => 1, ‘post_status’ => ‘publish’, ); … Read more

Complex Custom Loop with Includes

Here are some optimization suggestions for the code: Refactor the code structure: Currently, the code is using multiple if statements to determine which template to display for each portfolio item. This can be refactored to use a single switch statement. This will make the code more readable and easier to maintain. Remove redundant code: The … Read more

How to get rid of extra Untitled Article in html5 document outline when using new WP_Query?

Putting the answer I received via Twitter here for others to see: It was the sticky post under the Featured Comic section that was creating that phantom Untitled Article. So, by adding: ‘post__in’ => get_option( ‘sticky_posts’ ) to the arguments, it got rid of it. New code for the Featured Comic now looks like this: … Read more