Combine multiple CPT names to create valid permalinks

Sally CJ commented an important detail that helped me reach what I needed. Apart from that I struggled with what seemed to be regex error – one of my rules was overriding another because there was no $ character in regex to end the string. Working solution for custom rewrites: function dd_custom_rewrite_rules() { add_rewrite_tag(‘%company%’, ‘([a-z0-9-]+)’, … Read more

Create a permalink to a pdf?

You can accomplish the first part using the Quick Page/Post Redirect Plugin. Just set the Request URL to /resume and the Destination URL to /wp-content/uploads/2021/07/Resume-v4.pdf For the second part of your question, you can add a redirect rule to your .htaccess file: Redirect /wp-content/uploads/2021/07/Resume-old.pdf /resume The way you worded your question you actually would set … Read more

help with custom rewrite rules

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 . “https://wordpress.stackexchange.com/” and the URLs would end with a slash. However, … Read more

Custom Post Type posts, conflict with posts after add_rewrite_rule to top

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’ => ‘success-category’ ]); foreach ($categories as … Read more

Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?

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 in db with the WordPress … Read more

Get wordpress installation folder

You don’t need to do this. As long as your site URL in Settings is set to mydomain.tld/wordpress you don’t need to include /wordpress in your rewrite rules. If you look at the rewrite_rules option in the wp_options table you’ll see that none of the default rules are using it, because it’s not required.