New answers tagged

0

A STRAIGHT FORWARD AND CLEAN CODE I'm a newbie :) I modified the codes given by Adam and removed the unnecessary parts not needed to answer the initial question. It worked for me 100%. Give it a try. Please let me know if it worked for you too :) <?php $categories = get_the_category(); foreach ($categories as $category) : endforeach; ?> <a href=&...


1

In your WP_Query, only return ids. https://developer.wordpress.org/reference/classes/wp_query/#return-fields-parameter Create an empty array, $myArray = array();. Then loop thru the results of the query, $your_query->posts and fetch your field value for each id and add the result and the id to a new array in $myArray. Then sort the arrays in $myArray by ...


0

Or this: $query = new WP_Query( $args ); $count = $query->post_count;


0

Your HTML select tags for each level all have the same name and ID, and will overwrite each other. They must be unique. You will need separate names, IDs, and meta for each user level input. Likewise, the user meta keys need to be unique. The code also needs to use get_user_meta instead ( get_the_author_meta is only to be used inside a post loop ). I suggest ...


0

I found this item, that might be a good start; but the difference is that we need not to specify each specific category, the basic must be, one itme of all recent posts. how tho change number of posts in loop from specific categories


0

You can try something like this: if ( have_posts() ) : // define count var ## $count = 1; while ( have_posts() ) : the_post(); ?> <div class="class_bg_<?php echo $count; ?>">XXX</div> <?php // iterate ## $count ++; // reset count if reached 5 ## if( 5 == $count ){ $...


1

' publish', This is your problem, an extra space character. Note that in future you can catch this by using Query Monitor and by checking if posts were found. Because the post loop is missing an if ( $query->have_posts() ) { ... } else { echo "none found"; } type check, you had no way of knowing where to look for the problem. Also, you're ...


Top 50 recent answers are included