How to loop specific Category menu from archive page?
How to loop specific Category menu from archive page?
How to loop specific Category menu from archive page?
Sort posts according to a numeric value entered with ACF
if the result of query_posts($args) is the array of which you want to modify the order, something like that could possibly work: $the_posts = query_posts($args); $mypost = []; for ($i=0;$i<sizeof($the_posts);$i++){ if ($the_posts[$i][‘id’] === ‘196’): $mypost = $the_posts[$i]; unset($the_posts[$i]); endif; } if(!empty($mypost)): array_unshift($the_posts,$mypost); endif; //your loop with the new post array foreach $the_posts as $post_iteration: setup_postdata($post_iteration); … Read more
get_the_terms() returning wrong results inside of loop
Display category name of custom posts only once in the loop Which page template do you want to display the category name? category page or single page, I am pretty sure this code will work. <?php $category = get_the_category(); ?> <h2 style=”text-transform: uppercase;”> <?php foreach ( $category as $key=> $val ){ echo $val->cat_name .'<br>’; } … Read more
Compare ACF date field (if exists) and post date and order DESC
Fetch data from two custom post types and create multidimensional array for output to html table
get_children() Archive Template
Use the parse_query hook to override the default main query: add_action( ‘parse_query’, function ( WP_Query $wp_query ) { /** * Only apply our custom ordering when: * – We’re not in the admin * – It’s an archive (i.e. not singular) * – It’s the main query (won’t affect custom WP_Query) */ if ( ! … Read more
How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post