How to loop through yoast primary categories? [closed]

Managed to sort it, the primary category is added as post meta to the post, therefore you can pass through the following arguments: ‘meta_key’ => ‘_yoast_wpseo_primary_news-category’, ‘meta_value’ => 1179, Note: your meta key will be different since this is a custom taxonomy that I have set up, if you print the get_post_meta for your posts, … Read more

WordPress Alphabetical Sort Loop Issue

I would approach this a bit differently. You’re outputting all pages, so I would just get them all in one go. You can then iterate over each letter, run the loop, and compare the current letter with the page title to see if it matches. $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘orderby’ … Read more

I need to display all post in onepage

You can use WP_Query <?php $args = array( “post_type’ => ‘faq’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ‘posts_per_page’ => -1 ); $query = new WP_Query( $args ); if( $query->have_posts() ): ?> <ul id=”myUL” class=”margb-40″> <?php while( $query->have_posts() ): $query->the_post(); ?> //content <?php endwhile; ?> </ul> <?php wp_reset_postdata(); endif;

Posts are not looping through correctly

I just tested the following example code: <?php $the_query = new WP_Query( array( ‘posts_per_page’ => 12, ‘paged’ => get_query_var(‘paged’, 1) )); if ( $the_query->have_posts() ) { // display #ajax wrapper only if we have posts echo ‘<div id=”ajax”>’; while($the_query->have_posts()) { $the_query->the_post(); ?> <article <?php post_class(); ?>> <div class=”row”> <div class=”col-md-4″><?php the_post_thumbnail(‘medium-thumbnail’); ?> <h2><a class=”post-title” href=”https://wordpress.stackexchange.com/questions/252035/<?php … Read more

Infinite Loop – WP_Query

Your second loop, the $ticketQuery loop is missing $ticketQuery->the_post(). The function the_post() actually sets up things like template tags, the $post object. The most important thing it does is increments the post counter so that eventually $ticketQuery->have_posts() will eventually return false. Without the_post() is your infinite loop.

add offset to archive page

I am not sure what exactly you are trying to do. Here is an example using offset. For a category the first post is being displayed and that can have a unique HTML structure/layout. Then the remaining posts are shown but the search omits the first results and it offset by one item. Does this … Read more

Simple way to style posts of a single category differently in the loop and in single

I’m not sure I understand the question, since the answer seems straightforward, assuming standard templates – it’s conceivable that your theme does not provide the kinds of classes you are asking for, but IMO would be odd. It is standard practice for theme writers to include the function body_class() which adds different classes to the … Read more