0

I want to find a solution for the following problem:

On my website, I want to show a specific content on a certain page, e.g.: http://mysite.de/locations/location-xyz

locations is wordpress page location-xyz is a special location and should be replaceable with any other location (location-abc, location-sdf, uvw-location -> the exact slug of a location).

But I don't want do create a site for every single location. I've created a template file for the locations page and on this page I want to display information about the given location. If no location is given, I want to show the content of the locations page.

It is clear to me, that I could easy access the location wirth the following solution: http://mysite.de/locations/?location=location-xyz. But that's not the way I want to do it.

The problem is, that Wordpress automticlly tries to find the page "location-xyz".

Is there any possiblity to access the url-parameters?

Thanks!

  • Could this be a case for a custom post type of locations, with locations-xyz, locations-abc etc being categories? – alexwc_ Dec 6 '15 at 14:02
  • Is location a custom post type or a custom taxonomy term? Or a page? I would suggest a CPT or taxonomy instead, most likely a CPT. I'd also either avoid having a page called "locations", or call the page "locations" and use "location/locationxyz" as the URL structure, as it will greatly simplify your task – Tom J Nowell Dec 6 '15 at 15:17
  • locations is a page. And location-xyz etc. are not all different categories. All locations could belong to a category (e.g. "places" or "locations"). I want to build it up like an post (e.g. mysite.de/category-a/my-first-post). replace "category-a" with "locations" and "my-first-post" with "location-xyz". I haven't thougth about the post-type of my locations yet, but it won't be a page or a post.. – Brotzka Dec 6 '15 at 16:59
0

You might want to taker a look at add_rewrite_rule or add_rewrite_endpoint. Then to test, install a plugin called Monkeyman Rewrite Analyzer, it'll help you show you if your rules are conflicting.

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.