Calling a custom excerpt function in a local loop

Note, the excerpt_length filter does not work like that. It takes one parameter, $length, which is the word length of the excerpt. Updated solution First we wire up the callback function wpse_default_excerpt_length() to the excerpt_length filter. This is our default excerpt length handler. Next, some additional excerpt_lengthcallback functions are declared, but we won’t wire them … Read more

How to Get All Posts but the Private ones?

I believe get_posts returns all published (no-private posts) but does display password protected posts. In fact, by default, the standard WP_Query loop does this as well. So by default, private posts shouldn’t appear. If you wanted to display private posts for those logged in, and not those who are logged out, you could use the … Read more

Wp_query order by multiple custom fields?

$qry_args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘event’, // Post type ‘posts_per_page’ => -1, // ALL posts ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘year’, ‘order’ => ‘DESC’ ); add_filter( ‘posts_orderby’, ‘filter_query’ ); $all_posts = new WP_Query( $qry_args ); remove_filter( ‘posts_orderby’, ‘filter_query’ ); function filter_query( $query ) { $query .= ‘, post_modified DESC’; return $query; } … Read more

Querying Multiple Custom Taxonomy Terms

You’ll want to use the tax_query argument for query_posts/WP_Query. query_posts( array( “tax_query” => array( array( “taxonomy” => “country”, “field” => “slug”, “terms” => array( “usa”, “canada” ) ) ) ) ); The tax_query argument is an array, so you can query multiple taxonomies.

Display certain amount of posts on taxonomy archive page

Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the need to make changes for/in the templates? (Yes I know I also make queries in my templates but wanted to help out before leaving office) function wpse214084_max_post_queries( $query ) { if(is_tax(‘genre’)){ // change genre into your … Read more