I have a custom post type set up as Event. Within this post type I have various bit's of content / custom meta which will be used on two or three different pages.

I was wondering lets say I had my custom post type url as


and on that page I had 3 links that when clicked would load the relevant content i.e.



I could achieve what I want with query string parameters on the initial URL but was wondering if I could use pretty URL's rather than have http://www.mysite.com/my-custom-post-title/?subconten=faqs

I know you can do your own rewrites I am just not sure how best to approach it.


So assuming I have the following URL:


I have added the following action

add_action('init','custom_rewrites'); function custom_rewrites() { global $wp,$wp_rewrite,$wp_query; $wp->add_query_var('content_filter'); $wp_rewrite->add_rule('events/([^/]+)/info/([^/]+)/', 'index.php?post_type=portfolio&name=$matches[1]&content_filter=$matches[2]', 'top'); $wp_rewrite->flush_rules(false);
// print_r( $wp_rewrite ); }

Still nothing - I have found that if I dump query vars to the screen on the 404 page "direction" returns as attachment. Anyone have an idea how I can get this working?


  • Ok so here is an update:
    – user180386
    May 7, 2014 at 12:26

1 Answer 1


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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.