We’ve purchased a wordpress theme (Zerif Pro) and so far I haven’t been impressed with it. Our team needed to add quite a bit of hackery to make the website behave correctly since the theme is fragile, hardcodes settings that should be configurable and misuses some of WordPress’s functionality (ideally we’d throw this theme out and boycott Themeisle for future themes but we’ve come too far with the website at this point).
One of the things it misuses is the static front page. The theme does indeed build a static front page, but does so on top of “latest posts” page rather than doing it properly as WordPress would expect. This means that when we pick the “Front page displays a static page” option within WordPress settings, it breaks the theme. For that reason we have kept the main page as is and created a dummy page to contain latest posts instead.
The problem now, however, is that the main page, despite being a cover page, still somehow thinks it’s a blog page, which resulted in some other issues (like “share this post” links appearing on it, which we’ve hidden via css) and more recently the incorrect OpenGraph information, which is what this question is about.
The meta-data populated into the cover page (which is really the latest posts page incorrectly styled by the theme into a cover page) matches that of our latest post. I’m assuming it’s generated by wp_head()
, but can’t locate where this meta-data is coming from (the theme does not seem to override wp_head()
and we’re not using any SEO plugins that would be injecting og
meta-data). At this point, here are the solutions I’m thinking of:
- Override wp_head() to exclude this data (I’m not familiar enough with the logic to do so)
- Let the WP platform somehow know that the main page is not a blog post (this will prevent irrelevant OpenGraph data being pulled from latest blog post, again I have no idea how to do that)
- Tweak the theme to inject its “static” content into a different page rather than into the default latest posts page, where we could control the meta data via plugins (again, no idea where this logic is done or if this theme would even cooperate)
- Find where the OpenGraph meta-data gets populated and override it
Can someone suggest how to go about solving the problem (if you have a better solution than the 4 I mentioned above or any guidance on either of those 4, I’d appreciate it). If it helps, here are all currently installed plugins:
- Contact Form to Email
- Easy Twitter Feed Widget
- Featured Image From URL
- Google Analytics Dashboard for WP
- Posts in Page
- SendGrid
- Simple Custom CSS
- Social Share Buttons by Supsystic
- TC Custom JavaScript
- Typecase
- Widget Wrangler
- WP Client Logo Carousel
- WPide
This answer wouldn’t have been possible without Jevuska’s help, whose comment explained how to get the contents of
wp_head
, something I was completely clueless about before. These steps can be used to remove any unwanted logic fromwp_head
, not just theog
logic that bothered me. Here is what I did to resolve the issue:Added the following code to functions.php, as suggested by Jevuska:
Reloaded the page to see a giant dump of the hash containing various
wp_head
items, the items are displayed as key/value pairs with keys being the names and values being arrays with more data:[wp_oembed_add_discovery_links] => Array
Collected all the keys and inserted each entry into functions.php in the following format:
remove_action('wp_head', 'wp_oembed_add_discovery_links')
, I had about 20 total entries, I also removed the function from step 1.Reloaded the page and observed that the
og
meta data was gone, so was a lot of other stuff from the<head>
element. To narrow down to the offending element fast, I used binary search, removing half of the elements and seeing if it had an effect. Within 4 iterations, I found the culprit:fifu_add_social_tags
Leave
remove_action('wp_head', 'fifu_add_social_tags');
logic in functions.php to preventog
tags from rendering, remove all other lines.