How to insert a post from a different post type after every nth post

Figured out a solution that works for the issue I was having. This should be able to place an ‘Ads’ custom post type every 3rd post of ‘Articles’ custom post type. <?php // $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $get_posts = new WP_Query(array( ‘post_type’ => ‘articles’, ‘post_status’ =>’publish’, … Read more

How i can display all posts order by years

You need to add an if statement current loop to print out a year container around your articles. <?php if( have_posts() ) : ?> <?php $current_year = date(‘Y’); // Get the current year and set it $first = true; // Set a $first variable; while ( have_posts() ) : the_post(); if ( $first || get_the_date(‘Y’) … Read more

Loop posts without any taxonomy

One solution would be to give a value of “none” to your posts without any post group, similarly as you have “uncategorized” posts in WP Categories. Alternatively… I haven’t checked it, but why don’t you try to make another WP_QUERY like this: new WP_Query( array( ‘post_type’ => ‘page’, ‘page_group’ => ” ) )

Divide loop into several columns based on post custom field and enable infinite scrolling

Use something like this for each column. <!– custom field = ‘normal’ –> <div class=”span2 normal”> <?php // The Query $the_query = new WP_Query( array( ‘meta_key’ => ‘your_custom_field_name’, ‘meta_value’ => ‘normal’ ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); echo ‘<div class=”post”> <h1>’ . get_the_title() . ‘</h1> </div>’; endwhile; // Reset Post Data … Read more

Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen

Run through the loop once and break when the sticky post is found. If it’s not found, rewind the query and output the first found result: <?php if ( $featured_value_cat_query->have_posts() ) { $count = 0; while ( $featured_value_cat_query->have_posts() ): $featured_value_cat_query->the_post(); if ( ‘yes’ == get_field(‘seacoast_value_sticky_value’) ) { $count = 1; ?> // Post Content would … Read more

Get categories by title descendant

If only you could use get_categories() reference in the Codex, you could see that this function supports arguments. <?php $categories = get_categories( array( ‘orderby’ => ‘name’, // default value, can omit it ‘order’ => ‘DESC’ )); foreach($categories as $cat) { // your code goes here }