6

We are using Wordpress 4.2.2 & CiviCRM 4.6.1. We have a couple of fundraising events in which participants have the option of creating a Personal Fundraising Page.

When participants share their PCP URL on Facebook the link preview doesn't share any info from their PCP—Page Title, Description or Photo—and doesn't link to their page, it links to the Base page that has been set for CiviCRM in Wordpress.

Is there a way to add Open Graph tags to each PCP? I did see that Mathieu created a Drupal module that adds Open Graph tags on PCP pages for Facebook a few years back: https://github.com/mlutfy/civicrmogp. Does anyone had any ideas for Wordpress?

I do know that there are plugins for Wordpress that allow you to add Open Graph Meta tag info to your website. These allow you to set that info for individual Pages or Posts, however the PCPs are generated dynamically through CiviCRM using the base Wordpress page that I configured, so setting Open Graph info on that page would cause all the PCPs to share the same info on FB—unless I don't know what I talking about (which is totally possible).

Here are some screenshots to help show what I am talking about: This is what the link preview looks like when posted to Facebook

This the page that you are taken to when you click on the link preview

2

As you've discovered, this is not something that the WordPress plugin does by default. You can, however, hook into the 'civicrm_basepage_parsed' action that is fired when (ahem) the basepage has been parsed and roll your own Open Graph tags to be included in the markup via 'wp_head'. The content of the basepage is available via the 'basepage_render()' method of class 'CiviCRM_For_WordPress_Basepage', which can be externally accessed with the following code:

$content = civi_wp()->basepage->basepage_render();

Admittedly, this won't tell you what kind of Civi content is being included in the basepage, but the technique above will allow you to produce something more sensible than what you currently have.

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.