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

You can use question mark: RewriteRule ./?$ /index.php [L]


0

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


0

To do what you want you are going to have to add_rewrite_rule for each rule you have. I am storing new rules that users add to an options array. If the user wants to delete the rule, then once selected, I unset it from the array. function remove_rule($user_input){ foreach($rules as $key => $rule){ if($rule === $user_input){ unset(...


0

I've actually had a brain fart, and just figured it out.. Since I don't have any single posts, there was no reason to even be rewriting the CPT itself. I simply removed the rewrite line from the CPT and everything is working perfectly.


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 ...


3

since WP 4.4.0, you can use this filter that allows you to change the arguments used in the original cpt registration. Add this to your functions.php file: add_filter( 'register_post_type_args', function( $args, $post_type ) { if( 'wyde_portfolio' === $post_type && is_array( $args ) ) $args['rewrite']['with_front'] = false; ...



Top 50 recent answers are included