custom taxonomy and custom post type url conflict

Try this code. It may help you. class Tax_Seo_Perma { public function __construct() { // Hooks add_filter(‘rewrite_rules_array’,array($this, ‘create_rewrite_rules’)); add_filter(‘wp_loaded’, array($this, ‘flush_rules’)); add_filter(‘post_link’, array($this, ‘modify_link_addresses’), 10, 3); //add_filter(‘post_type_link’, ‘tsp_write_link_addresses’, 10, 3); } public function flush_rules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); } public function create_rewrite_rules($rewrite) { global $wp_rewrite; // loop through custom taxonomies $args = array( ‘public’ => true, … Read more

How to do a query on custom taxonomies that is uncategorised?

Okay thanks for all the helpful comments. It turns out there is no way to do this using WP_QUERY alone. The best way I can think of is to do it is like so: $taxIds = get_terms($options[‘post-types’][$this->current_post_type->name], array( ‘fields’ => ‘ids’, )); $uncategorisedQuery = new WP_Query( array( ‘post_type’ => $postType, ‘posts_per_page’ => -1, ‘tax_query’ => … Read more

How to add rewrite rules and pagination to retrieve attachments files?

Based on the comments of @Milo and using the rewrite analyzer plugin I found what I understand as a conflict in the rewrite rules?. The following url: exams/high-school/city-name/subject/math/ matches the following rules Pattern: (.?.+?)/page/?([0-9]{1,})/?$ Subtitution: pagename: exams/high-school/city-name/subject/math paged: 1 Pattern: (.?.+?)(/[0-9]+)?/?$ Subtitution: pagename: exams/high-school/city-name/subject/math/page page: /1 Pattern: exams/([^/]+)/([^/]+)/subject/([^/]+)/?$ Subtitution: pagename: examns level: high-school city: city-name … Read more

How to add custom taxonomy slug in CPT permalink?

I solved this way: Register Custom Post Type: function custom_post_articles() { $labels = array( ‘name’ => _x( ‘Articles’, ‘post type general name’, ‘textdomain’ ), ‘singular_name’ => _x( ‘Article’, ‘post type singular name’, ‘textdomain’ ), // etc… ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘menu_position’ => 5, // Below Posts. ‘menu_icon’ => ‘dashicons-megaphone’, … Read more