Tag Info

Hot answers tagged

3

I would take a different approach to this using a direct database query to get a list of author IDs ordered by recent posts. global $wpdb; $user_ids = $wpdb->get_results( " SELECT DISTINCT post_author FROM $wpdb->posts ORDER BY post_date DESC " ); if ( $user_ids ) { foreach ( $user_ids as $user_id ) { $user = ...


2

The post_excerpt value is empty because you have no explicit excerpts for your posts. While the_excerpt() does generate an excerpt from the posts content if the post excerpt is empty, the function wp_get_recent_posts(), which is basically a wrapper for get_posts(), doesn't.


1

This code could work, I'm using the setup_postdata to create a post object similar to what the function the_post() does, so now you can use the functions you have in a Loop. $recent_posts = wp_get_recent_posts( array( 'numberposts' => 3, 'orderby' => 'post_date', 'order' => ...


1

The function you are using, get_most_recent_post_of_user, won't work as it only retrieves the latest post from the author. It cannot retieve a list of posts Walks through each of a user's blogs to find the post with the most recent post_date_gmt. You will most probably be better of using either WP_Query or get_posts to achieve this. You should first ...


1

I would tend not to go with wp_get_recent_posts or even get_posts for custom queries like this. By default, template tags like the_excerpt() is not available to these functions, and you have to make use of setup_postdata($post) to have access to these template tags. I would personally use WP_Query in a case like this which is more flexible, specially when ...


1

You have to reset every instance of a custom query, otherwise you will get unexpected output from any other query there after Simply use wp_reset_postdata() after every custom query. Example <?php $args = array( 'numberposts' => '1', 'meta_key'=>'_thumbnail_id' ); $recent_posts = wp_get_recent_posts( $args ); foreach($recent_posts as ...


1

The arguments you are using are wrong. They should be: $args = array( 'numberposts' => '10', 'post_type' => 'post', 'post_status' =>'publish', 'tax_query' => array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => array( 10, 11, 57 ...


1

get_the_content() returns unfiltered content, and using a shortcode you cannot use the_content() to return filtered content as you cannot echo inside a shortcode. Your best option here will be is to applying the_content filters to get_the_content(), something like: apply_filters( 'the_content', get_the_content() ); EDIT Exact usage, replace $output .= ...



Only top voted, non community-wiki answers of a minimum length are eligible