Social Sharing

The site I am working on is http://fortworthfotofest.com/events/. I found the following code from a previous inquiry and inserted it into my child theme’s functions.php to add share buttons to the posts, but I can’t figure out how to get this to also extend to my events.

> // Add Social Sharing after the single post content
> // =============================================================================

> function x_add_social_sharing ( $content ) {
>   if ( is_singular('post') ) {
>     echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
>   }
> }
> add_action('x_before_the_content_end', 'x_add_social_sharing');

Additionally, the share buttons on Essential Grid are not functioning properly when edited through EG Skin Editor. Below is a screenshot of what the grid looks like - I want the icons to function as share buttons on hover.

Also, each event has it’s own Eventbrite page, so I’d like the ‘Register Now’ button to be able to hyperlink to each individual link. Currently, the ‘REGISTER NOW’ button is custom meta. I’ve tried to edit the meta data in each post to hyperlink out to the event’s page on Eventbrite by posting
<a href="https://www.eventbrite.com/e/fort-worth-foto-fest-successful-real-estate-photography-tickets-43449519683" target="_blank">REGISTER NOW</a>
in the available space, but it tries to link internally to
http://fortworthfotofest.com/events/%3Ca%20href=%22https:/www.eventbrite.com/e/fort-worth-foto-fest-successful-real-estate-photography-tickets-43449519683%22%20%20target=%22_blank%22%3EREGISTER%20NOW%3C/a%3E

Any help would be greatly appreciated.

Hi There,

Thank you for writing in, on your line of code above, please update this line:

if ( is_singular('post') ) {

to this:

if ( is_singular() ) {

Please provide us login credentials in a secure note so we can take a closer look on the Essential Grid issue.

Cheers!

Here ya go!

Also, I made the change to the function.php which did work for putting the sharing buttons on the bottom of the events pages, but it also added the share buttons to the bottom of all other pages as well. How do I specify these to only apply to the posts pages and the eventbrite events pages?

Hi There,

Please update the condition to this:

if ( is_singular( array('post', 'event') ) ) {

I updated the condition and the issue was not corrected. I imagine it has to do with the post type name. I’m not sure what the post type is for the eventbrite events and I’m unsure exactly how to figure that out.

Hi,

The post type name is eventbrite_events

I went ahead and change the code to

function x_add_social_sharing ( $content ) {
  if ( is_singular( array('post', 'eventbrite_events') ) ) {
    echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
  }
}
add_action('x_before_the_content_end', 'x_add_social_sharing');

Thanks

You rock! Another question, the share buttons on Essential Grid are not functioning properly when edited through EG Skin Editor. The Share buttons that show when hovering over the event on the grid live on the page are not functioning properly. Do you have a solution for this?

Thank you incredibly

Hi there,

Looks like it’s a bug, I can confirm that in my installation. I’ll add this to our issue tracker. For the meantime, you can remove the social icons and let your visitors share it through its single pages.

Thanks!

Ok, thank you for the heads up.

You’re welcome.

Hi guys, is there a way to share at the end of the excerpts?

I originally had the following code but it stopped working:

function x_add_social_sharing() {
echo do_shortcode(’[x_share title=“Share this Post” facebook=“true” twitter=“true” google_plus=“true” linkedin=“true” pinterest=“true” reddit=“true” email=“true”]’);
}
add_action(‘x_before_the_excerpt_end’, ‘x_add_social_sharing’);
add_action(‘x_before_the_content_end’, ‘x_add_social_sharing’);

I changed to the one you suggest in this post but can’t figure how to combine for it to show on excerpts :slight_smile: thank you so much!

Hi,

The code I provided above is for single post and event page.

Excerpts are usually generated on archives page, so you can try adding this code together with the code above.


function x_add_social_sharing_excerpt ( $content ) {
  if (is_post_type_archive(array('post', 'eventbrite_events'))) {
    echo do_shortcode('[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
  }
}
add_action('x_before_the_excerpt_end', 'x_add_social_sharing_excerpt');

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.