• samuelmarcinko

    (@samuelmarcinko)


    Hello guys, I have a website and I created a post. Each post has multiple categories so WordPress automatically set one of them to Primary. I’m displaying category (parent category) title on each post in header section. But the problem is that we want to send a newsletter and this newsletter should contain link to this post but each link should display different category title in header. Here is example.

    My post is assigned to Category A, Category B and CATEGORY C. I can access to this post using multiple categories but the URL is always redirected to Primary category so even the Category title is changed do primary. And I need following:

    I dont want to set primary category to post, I just want to assign this post to 3 categories and access to this post using URL and display in header section category title according to which category I clicked through to it. If I clicked through the url /categoryA/myHouse then there will be CATEGORY A if I send to my client link /categoryB/myhouse then there will be in header section CATEGORY B.

    It is possible ? thank you guys.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    WP by default will redirect requests to the related canonical URL. You can suppress this behavior through the “redirect_canonical” filter hook.

    If you do that, double check the rel=”canonical” link tag in a post’s head section for each request to verify it’s always the same URL regardless of requested category. If it should change by category request for the same post, you’ll get a SEO demerit for duplicate content.

    Thread Starter samuelmarcinko

    (@samuelmarcinko)

    So it is possible to do that solution I wrote above ?

    Moderator bcworkz

    (@bcworkz)

    Yes, you’d likely need custom header code to display the requested category term instead of the primary term. The current code (theme dependent, YMMV) likely gets the primary from the DB and doesn’t actually check the request. And you need to prevent the redirect through “redirect_canonical” filter, otherwise the requested term would be forgotten by the time the header code executes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple category names in header’ is closed to new replies.