WordPress adding a tag and changing the URL on load

I have a custom post type “profile”
I need the same profile to load when requesting 3 differnt URLs, example:

  • mysite.com/city1/bob
  • mysite.com/city2/bob
  • mysite.com/city3/bob

These should all load bob’s profile.

Read More

I added the cities as categories and assigned bob to each category.

Now when I go to these links they all load bob’s profile, but the URL changes on load. I want to stop the URL from changing.

Example:

  • mysite.com/city1/bob loads the page, but becomes
    mysite.com/city1/tag1/bob
  • mysite.com/city3/bob loads the page, but becomes
    mysite.com/city1/tag1/bob

I need it to stop adding the tag, and I need it to stop switching to city1.

How can I do this in wordpress?

The permalink is set as /%category%/%postname%


update, I am using a curl request in my 404 page to load the content for now as a hack:

$c = curl_init(get_site_url() . '/blog/people/'.$the_slug);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);


$html = curl_exec($c);
echo $html;

But I am sure this is not the best way to do it, I am trying to use add_action( ‘template_redirect’,’myfunction’) which is working to detect the url and load the post I want into a variable, but I can’t seem to set the $post global to that post. It just ends up loading the homepage.

Is this possible: User requests URL that does not exist, I use a hook like template_redirect and render a page based on what they requested, and leave the URL as what they requested? Can I do this without curl?

Related posts

Leave a Reply

2 comments