Rewrite rule is catching pages not posts

You are using the pagename query var, so, like the name suggests, you are requesting a page with the specified name and not other type of content/post. If you want the rewrite rule works for all types of post (except attachments), you can use the p query var passing the post_ID as value. See the … Read more

Custom URL scheme – paramters on custom post type

Try rewrite endpoints: function wpse_143634_endpoint() { add_rewrite_endpoint( ‘info’, EP_PERMALINK ); } add_action( ‘init’, ‘wpse_143634_endpoint’ ); Now you’ll find you can visit any post and tack on info/whatever to the URL – WordPress will still load the post, except now you’ll have get_query_var( ‘info’ ) == ‘whatever’. Further reading: https://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/

Why isn’t my custom function kicking in from my functions.php file?

It isn’t working because you’ve mixed up returning values and echoing values updateToPerfectURLs(the_permalink()); Here updateToPerfectURLs returns its value, but you’ve not printed it out. Try echo/etc Your second problem is the opposite, the_permalink() doesn’t return the permalink, it echos it out. So before you’ve even gotten into the function the permalink is printed out. Use … Read more

Multiple URL from Custom post name

You can add a query var and a rewrite rule to handle the extra URL data- Add the wpd_cf query var to the list of known query vars: function wpd_add_query_var( $query_vars ){ $query_vars[] = ‘wpd_cf’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_add_query_var’ ); Add a rewrite rule to handle the incoming requests and set the wpd_cf … Read more

custom url with custom post

You can omit the “base”, by adding rewrite => array( slug => ‘item’, with_front => false, ), Don’t forget to flush your rewrite rules after you changed that. The easiest way to do so it to simply visit the “admin > settings > permalinks” page. If you need to add that to an already registered … Read more