meta_query not working properly

Based on the codex, the meta_query parameter contains one or more array with the relation parameter not set if single inner meta_query array. Also remove the page parameter as it serves only for a Static Front Page. Your args array should look like that: $archive_args = array( ‘post_type’ => ‘speight_home_plans’, ‘orderby’=> ‘title’, ‘order’ => ‘ASC’, … Read more

How to exclude categories from recent posts, recent comments & category widgets?

The original author isn’t quite right in saying “which is merely the more elegant way to write”. set_query_var() will always override the main query, whereas if you actually use: $wp_query->set( ‘category__not_in’, $excluded ); … it will work for any instance of query_posts(), such as the recent posts widget.

Add thumbnail to recent posts widget using filters

Here’s one way to do it through the the_title filter. We can limit the scope to the Recent Posts widget, by initialize it within the widget_posts_args filter and then remove it again after the loop. /** * Recent Posts Widget: Append Thumbs */ add_filter( ‘widget_posts_args’, function( array $args ) { add_filter( ‘the_title’, ‘wpse_prepend_thumbnail’, 10, 2 … Read more

Modifying recent post widget to include icons for post titles

Here’s an example how to prepend a span tag to the post titles, where the span class is added in the custom field wpse_post_icon_class. We could try to restrict it to the Recent Posts widget with: add_filter( ‘widget_display_callback’, function( $instance, $obj, $args ) { // Only target Recent Posts widgets if( ‘recent-posts’ === $obj->id_base ) … Read more

Display all comments or recent comments per user on author page

your problem is using author_email, you need user_id: i just use similar script. <?php $args = array( ‘user_id’ => get_the_author_meta(‘ID’), ‘number’ => 10, // how many comments to retrieve ‘status’ => ‘approve’ ); $comments = get_comments( $args ); if ( $comments ) { $output.= “<ul>\n”; foreach ( $comments as $c ) { $output.= ‘<li>’; $output.= … Read more

Querying post from a multisite network

You could use your list of blog ids in this way … $posts = array(); foreach ( $your_list_of_blog_ids as $blog_id ) { switch_to_blog( $blog_id ); $query = new WP_Query( array( ‘post_type’ => ‘any’, ‘posts_per_page’ => 10, ) ); while ( $query->have_posts() ) { $query->next_post(); $posts[] = $query->post; } restore_current_blog(); } Important are switch_to_blog and restore_current_blog. … Read more