Remove CPT Slug with 2 taxonomies and 1 post meta

Managed to get it sorted in the end, needed to add a rewrite rule (see below) if you need full source code then let me know and I will be more than happy to paste it. public static function add_rewrite_rules() { add_rewrite_rule( ‘^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?’, ‘index.php?post_type=products&product_holiday=$matches[1]&_product_countries=$matches[2]&_product_types=$matches[3]&name=$matches[4]’, ‘top’ ); } add_action(‘init’, array( __CLASS__, ‘add_rewrite_rules’) ); Thanks,

How to add add blank non-editable wp page like default blog for use with plugin

You can do it by hooking admin_init action: First, you can create a option to select the page you create for your plugin. I suppose that the option will be save in wp_options table with name your_plugin_special_page. Remove editor support on that page with this action. add_action( ‘admin_init’, ‘your_plugin_hide_editor’ ); function your_plugin_hide_editor() { // Get … Read more

redirect any category in URL to the ID and post-name only – hundreds of pages affected

I’d suggest you to forget about htaccess in this case. In your functions.php file add: add_action( ‘template_redirect’, ‘check_missing_urls’ ); function check_missing_urls() { if ( ! is_404() ) { return; } $has_match = preg_match( ‘/\/?(\d+)/’, $_SERVER[‘REQUEST_URI’], $match ); if ( ! $has_match ) { return; } $new_url = get_permalink( $match[1] ); if ( ! $new_url ) … Read more

Custom Post Types and Broken Permalinks

You need to flush rewrite rules on plugin activation for your custom post type to begin working. register_deactivation_hook( __FILE__, ‘flush_rewrite_rules’ ); register_activation_hook( __FILE__, ‘myplugin_flush_rewrites’ ); function myplugin_flush_rewrites() { // call your CPT registration function here // (it should also be hooked into ‘init’) dwwp_register_post_type(); flush_rewrite_rules(); } You may have noticed it randomly working without having … Read more

Restructuring permalink with more than one taxonomies

That’s quite possible by changing add_permstruct or filtering rewrite_rules. But what is your strategy for generating links for city? How will implement second taxonomy? I would go for implementing this as rewrite rule for something like add_filter( ‘rewrite_rules_array’, function( $rules ) { global $wp_rewrite; $new_rules = array( ‘(company|profession)/([^/]+)/([^/]+)/?$’ => ‘index.php?$matches[1]=$matches[2]&city=$matches[3]’ ); $rules = array_merge($new_rules, $rules); … Read more

Custom permalink for one category

Your rewrite rule doesn’t capture anything. Change: ‘^blog/?’ to add the capture group you reference with $matches[1] in your rule: ‘^blog/([^/]+)/?’ visit the Settings > Permalinks page, which will flush rules, and your code should otherwise work.

Prevent Archive URLs

WordPress generates date archives automatically, it’s just a thing it does. You see the index.php template probably because there isn’t a more specific one for date archives in your current theme. There are plugins that disable these archives, Yoast SEO is one. A quick fix is to empty the date archive rewrite rules: add_filter( ‘date_rewrite_rules’, … Read more