Put post ID on the custom post type URL

It’s quite easy, actually: Change the generated permalink structure so that it ends with the post ID and not the post slug (but it still contains the post slug): // After you registered the post type: register_post_type( ‘ex_article’, $args ); // .. run this code: global $wp_rewrite; $wp_rewrite->extra_permastructs[‘ex_article’][‘struct’] = ‘sa/%ex_article%/%post_id%’; Then replace the post ID … Read more

wp_sanitize_redirect strips out @ signs (even from parameters) — why?

Question why does wp_sanitize_redirect strip out @ signs, exactly? Anybody could anyway try to load a url with an @ sign in it – is there some security issue I’m not thinking about? Just take a look at the source: function wp_sanitize_redirect($location) { $location = preg_replace(‘|[^a-z0-9-~+_.?#=&;,/:%!]|i’, ”, $location); $location = wp_kses_no_null($location); // remove %0d and … Read more

Permalink Structure problem with cpt and custom taxonomy

Welcome to WP StackExchange! You may want to try something like this, which uses the same rewrite setting as your register CPT: $args = array( ‘rewrite’ => array(‘slug’ => ‘events/ecat’, ‘with_front’ => false) ); register_taxonomy( ‘ecat’, array( ‘events’ ), $args ); Sources: https://cnpagency.com/blog/the-right-way-to-do-wordpress-custom-taxonomy-rewrites/ https://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments

How Can I Have A URL Changed Based on the Originating URL?

You can use the page_link filter with the same logic as the page_template filter in the other answer. If the endpoint query var is set, then any link to a page gets the app-view/ appended: function wpd_page_link( $link, $post_id ){ global $wp_query; if( isset( $wp_query->query_vars[‘app-view’] ) ){ return $link . ‘app-view/’; } return $link; } … Read more

Rewrite custom post & taxonomy to share same URL path

(Revised on March 7th 2020 UTC) So sharing the same permalink path (or rewrite slug/base as in example.com/<rewrite slug>/<term slug> and example.com/<rewrite slug>/<post slug>) is possible, and here’s the (updated) code which enables you to share the exact same rewrite slug between a taxonomy and a post type: function wpse_358157_parse_request( $wp ) { $path=”about-us/video-center”; // … Read more