New answers tagged

0

I think I solved my problem. So if you have your WordPress post permalink set to %category%/%postname%/, and you want this for custom post type and taxonomy, you could prepare your rewrite links for all generated taxonomy terms (cat-a, cat-b etc.). Code: add_filter( 'rewrite_rules_array', function($rules) { $categories = get_terms(['taxonomy' => '...


1

By default, WordPress disallow 2 identical slugs because if you change your permalink structure for custom structure, you should be able to have in your case: https://example.com/saint-louis/ https://example.com/saint-louis/ And you can understand, it's impossible. The only way is checking by code, you are not in "custom structure" and then save ...


0

The issue with your updated code is that because you are using add_rewrite_rule() inside the filter, it can't properly add it to the top of the list. You can see this if you dump out the $rules array. Because it gets added to the end of the $rules list, WP steps in beforehand to match on slug alone using some magic in the background. In order to circumvent ...


1

The part that modifies the blog post URLs/permalinks is in the mandoe_update_post_link() function (which is hooked on post_link), and the part that you need to adjust is this: return home_url( '/blog/' . $post->post_name ); Just change the '/blog/' . $post->post_name to '/blog/' . $post->post_name . '/' and the URLs would end with a slash. However, ...


0

See this is sort of solved in the comments and old but to save someone going down the wrong path here, I believe this is done the wrong way for OP to achieve what they want. One re-write rule should be enough here, and then use the matches to construct your query. Firstly, we need a Regex that will match the whole string of what you're trying to parse ...


Top 50 recent answers are included