WordPress add_permastruct unwanted matches

I’ve been struggling all morning to solve this and found your question when searching for the answer. I’m sure it’s a little late for you now but in case anyone else stumbles across this question here’s the solution I found: Change: $wp_rewrite->add_permastruct(‘competition’, ‘/au/%prize_category%/%competition%/’, false); To: $wp_rewrite->add_permastruct( ‘competition’, ‘/au/%prize_category%/%competition%/’, array( ‘walk_dirs’ => false ) ); walk_dirs … Read more

Customize my custom taxonomy table in Admin panel

This should do the trick: add_action( ‘admin_print_styles’, ‘cor_admin_print_styles’, 200 ); function cor_admin_print_styles() { $screen = get_current_screen(); if ( ‘edit-tags’ === $screen->base && ‘department’ === $screen->taxonomy ) { echo <<<EOF <style> .fixed .column-posts { width: auto; } .widefat .num, .column-comments, .column-links, .column-posts { text-align: left; } </style> EOF; } }

Show posts from two or more custom taxonomy terms

You need to combine two tax queries with and AND relation: $args = array( ‘posts_per_page’ => 10, // Number of posts per page ‘post_type’ => ‘classifieds’, // Custom Post Type like Movies ‘tax_query’ => array( ‘relation’ => ‘AND’ array( ‘taxonomy’ => ‘classifieds_tags’, //Custom Taxonomy Name like Genre ‘field’ => ‘slug’, ‘terms’ => array( ‘books’ //Tags … Read more

WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term

You can try: $the_query = new WP_Query( array( ‘posts_per_page’ => ‘5’, ‘v_sortby’ => ‘views’, ‘post_type’ => array( ‘post’, ‘music’, ‘videos’, ‘albums’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘content’, ‘field’ => ‘slug’, ‘terms’ => array( ‘indy’ ), ‘operator’ => ‘NOT IN’ ) ) )); to exclude the indy term in the content taxonomy.

Mapping Subdomains in WordPress to give the appearance of a localised site, best approach?

Sort of a vague question, but I think I understand what you’re getting at. You’d need to use a WordPress Multisite installation, which will effectively create localized blogs on a subdomain (brisbane.example.com, perth.example.com). Using a single site WordPress installation to do this is possible, using CNAME mapping on the domain, however this would not suit … Read more

How can I make my custom posts appear in their assigned category url?

The query_posts solution is not reccomended (see you don’t know query). You should use pre_get_posts hook instead. See: function my_extend_category_by_custom_post_type( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ‘post_type’, ‘any’ ); } } add_action( ‘pre_get_posts’, ‘my_extend_category_by_custom_post_type’ ); PS: this should go into your functions.php if (custom post type is set from there) … Read more

Wp_query: sort by PHP variable

To the best of my knowledge, you cannot sort a query by two different parameters without an additional iteration over the retrieved posts. Since that ideally should be avoided, let me suggest a different approach: How about incorporating an additional meta value “sort_date”, or the like? And then, in your saving routine, save either the … Read more

Categories sorting

You have orderby=count, which should be correct, but you also have order=asc. order=ASC means “smallest to largest”, at least with numbers. You want the opposite, “largest to smallest”. Use order=DESC instead. I suspect that get_terms is working, you’ve just told it something different that you actually want. Also, you have multiple queries in a loop … Read more