2

I've discovered whilst typing my question a small exchange on this at Adding a URL hash into meta data for Facebook and Twitter share cards which suggests that this may not be feasible but as things change over time I thought I'd seek guidance.

The scenario:

I have a URL http://example.com/ which includes appropriate Facebook meta in the header. I'm most interested in:

<meta property="og:image" content="whatever.jpg" />

At a later date I may add some additional info on the page and link to it with an anchor - e.g. http://example.com/#new and may want to display different meta for that anchor, e.g.

<meta property="og:image" content="whatever-another.jpg" />

My question is, is there any way to dynamically change the meta depending on whether the URL shared is the original URL or the URL with an anchor. The page could have multiple anchors.

My site uses Wordpress so I can use things like custom fields, etc if they are a possible manual solution but whatever, the ability to change the meta field based on the URL anchor is the goal.

Appreciated any guidance.

Community
  • 1
  • 1
Paul Brown
  • 83
  • 11
  • 1
    possible duplicate of [Can PHP read the hash portion of the URL?](http://stackoverflow.com/questions/940905/can-php-read-the-hash-portion-of-the-url) – brasofilo Sep 30 '14 at 11:45
  • Thank you @brasofilo - that link didn't come up when I asked the question so thanks for the signpost. I guess the answer is can't be done. That's fine, I'll stop trying to figure it out :) – Paul Brown Sep 30 '14 at 12:33
  • As a matter of fact, it costed me a bit until hitting the right keywords ;) – brasofilo Sep 30 '14 at 22:58

0 Answers0