WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a post-meta field for Neighborhood. I want to setup a url like: url.com/neighborhood/NEIGHBORHOOD-NAME

I know this would typically be handled by a CPT or custom taxonomy but it has to be done with a post-meta field in this case.

I also want this to use a custom template, not one of the standard templates.

I can easily link to the url but it returns a 404 page because nothing is associated with it.

Wordpress doesn't know what content to grab. Any ideas?

share|improve this question
up vote 0 down vote accepted

There's the core function add_*/get_query_arg() that you can use to append stuff to the query and retrieve it.

So simply add a link somewhere, that points to your custom post types single.php template


Then append the query arg which would be ?wpse_meta_key=wpse_some_val and then do a switch on top of your template:

if ( 'wpse_some_val' === get_query_arg( 'wpse_meta_key' ) )
    get_template_part( 'special_query_template' );
    // do default stuff
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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