Adding Post Counts to Menu (Nav) Programmatically?

WordPress’ get_categories() function returns an array of category objects, each of which has a “count” property for the number of posts in that category. So something like this would get you a list of links to category pages: $categories = get_categories(); $markup = ‘<ul>’; foreach( $categories as $category ) { $catName = $category->category_nicename; $count = … Read more

How to get_queried_object on multiple objects?

You almost had it with $_GET[‘zap_audience’], but not quite, since it isn’t passed in as a GET variable. It is however a query variable, so try these: $post_type = get_query_var( ‘post_type’ ); $audience = get_query_var( ‘zap_audience’ ); $city = get_query_var( ‘zap_cities’ ); Also +1 for prefixing your taxonomy types with zap_

Searching user meta using WP_User_Query

Try this: $yoursearchquery = ‘This is my search’; $users = new WP_User_Query(array( ‘search’ => $yoursearchquery, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘shoe_size’, ‘value’ => $yoursearchquery, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘shoe_color’, ‘value’ => $search_operation, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘shoe_maker’, ‘value’ => $yoursearchquery, ‘compare’ => ‘=’ ) ) … Read more

Secondary loop pagination on custom post type single post gets redirected to first page

I found the answer. I had searched high and low yesterday, but today I finally found it: https://wordpress.stackexchange.com/a/143837/10595 add_action(‘template_redirect’, function() { if ( is_singular(‘posttype’) ) { global $wp_query; $page = (int) $wp_query->get(‘page’); if ( $page > 1 ) { // convert ‘page’ to ‘paged’ $query->set( ‘page’, 1 ); $query->set( ‘paged’, $page ); } // prevent … Read more

SQL Statement generated by WP_Query not producing expected results

It looks like this section: AND (wptom_posts.post_status=”publish” OR wptom_posts.post_author = 1 AND wptom_posts.post_status=”private”) is not tied in at all to the two different query conditions… Perhaps the original code should be three conditions for part 1: array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘operator’ => ‘IN’), array( ‘taxonomy’ => ‘post_tag’, ‘field’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)