New answers tagged

2

I found solution! A Monkeyman Rewrite Analyzur plugin was very helpful: https://wordpress.org/plugins/monkeyman-rewrite-analyzer/ So now, I have such working urls... single.php: /magazine-name/issue-year/issue/article-name archive.php: /magazine-name/issue-year/issue /magazine-name/issue-year /magazine-name On a custom post editor page in wp-admin I ...


0

As someone else suggested, I reactivated my theme and it started working!


2

1. Change new_category taxonomy's rewrite rule while registering: 'rewrite' => ['hierarchical' => false, 'with_front' => false, 'slug' => 'news'] Make sure rewrite rule of news post type is default or: 'rewrite' => ['slug' => false, 'with_front' => false] 2. Add rewrite rules for new_category: add_action('init', function() { ...


2

This is why you need to add rewrite rules on the init action on every request, as well as on plugin activation. When your plugin deactivation hook is run, other plugin init hooks have already run, so their rules exist in the global variable that stores them for the life of each request. Flushing rewrite rules empties the option that stores the rules long-...


2

1. Add a new rewrite rule: add_action('init', function() { add_rewrite_rule('^dog/([^/]+)/?$', 'index.php?cat=dog&name=$matches[1]', 'top'); }, 10, 0); 2. Filter the post link: add_filter('post_link', function($post_link, $post, $leave_name = false, $sample = false) { if ( is_object_in_term($post->ID, 'category', 'DOG') ) { $...


0

As far I understand, you know are able to have an URL like example.com/recipes/dinner/ or example.com/recipes/lunch/ but now you also want to have an URL like example.com/recipes/dinner-lunch/ that pulls posts from both "dinner" and "lunch" courses. In currents state of WP rewrites this is not possible just with add_rewrite_rule but you also need to use ...



Top 50 recent answers are included