• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Genesis Simple Share Pinterest Button

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Genesis Simple Share Pinterest Button

This topic is: not resolved

Tagged: Genesis simple share, pinterest

  • This topic has 2 replies, 3 voices, and was last updated 6 years, 11 months ago by Adam Bradford.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 17, 2016 at 7:22 am #183774
    hudsonandseine
    Member

    If I try to share my post on Pinterest, it automatically pulls the featured image and uses the post title for the description. Being that my featured images are horizontal with no text, they make horrible Pinterest images. I would like to configure it to be able to give people an option of what image to pin and to pull from the alt text for each image. Is there a way to change the settings to accomplish this?

    http://www.hudsonandseine.com
    April 17, 2016 at 11:30 pm #183808
    Christoph
    Member

    Hi,

    I don't think that will be possible without extensive code additions to the plugin.

    You can set a special pinterest image and pinterest description with https://warfareplugins.com/
    I would guess that other premium sharing plugins offer similar functionality.


    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

    April 18, 2016 at 7:37 am #183826
    Adam Bradford
    Member

    We could add custom field support with just a few minor tweaks
    Below is my patch.

    Basically, it updates Simple Edits to check for {network}_image, {network}_text
    Returns the data if it's there, if not it continues as usual.

    For pinterest,
    You'd add pinterest_image for the name, and the value would be the url of the image
    && pinterest_text for the text you want to show

    commit c09acf1747037626cbf2e195f11ed76bb3a5a7a8
    Author: admbradford <[email protected]>
    Date:   Mon Apr 18 09:32:36 2016 -0400
    
        Added custom field support
    
    diff --git a/lib/front-end.php b/lib/front-end.php
    index cc06ed9..5bd1497 100644
    --- a/lib/front-end.php
    +++ b/lib/front-end.php
    @@ -352,10 +352,9 @@ class Gensis_Simple_Share_Front_End {
     
     			$div_id =  strtolower( $icon .'-'. $location .'-'. $id );
     
    -			$image = ( $image = genesis_get_image( array( 'format' => 'url', 'size' => 'full' ) ) ) ? $image : $this->get_first_image();
    +			$image = $this->get_share_image( $id, $icon );
     
    -			$image = $image ? $image : genesis_get_option( 'image_url', 'genesis_simple_share' );
    -			$description = the_title_attribute( array( 'echo' => false ) );
    +			$description = $this->get_share_description( $id, $icon );
     
     			//media
     			$button = 'twitter'   == $icon && ( $via = genesis_get_option( 'twitter_id', 'genesis_simple_share' ) ) ?  " twitter: { via: '". str_replace( '@', '', $via ) ."' }" : '';
    @@ -561,6 +560,48 @@ class Gensis_Simple_Share_Front_End {
     
     	}
     
    +	/**
    +	 * Get the share image for a social network
    +	 * @param  int    $id      the post id
    +	 * @param  string $network name of social media network
    +	 * @return string URL of image to share
    +	 */
    +	function get_share_image( $id, $network ) {
    +		$key = sprintf( "%s_image", $network );
    +		$image = get_post_meta( $id, $key, true );
    +
    +		if( ! empty( $image ) && file_exists( $image ) )
    +				return $image;
    +
    +		$args = array(
    +		     'post_id'	=> $id,
    +		     'format'	=> 'url',
    +		     'size'		=> 'full'
    +		);
    +
    +		$image = ( $image = genesis_get_image( $args ) ) ? $image : $this->get_first_image();
    +
    +		$image = $image ? $image : genesis_get_option( 'image_url', 'genesis_simple_share' );
    +
    +		return $image;
    +	}
    +
    +	/**
    +	 * Gets the share text for a social network
    +	 * @param  int    $id      the post id
    +	 * @param  string $network name of social media network
    +	 * @return string text to share
    +	 */
    +	function get_share_description( $id, $network ){
    +		$key = sprintf( "%s_text", $network );
    +		$description = get_post_meta( $id, $key, true );
    +
    +		if( ! empty( $description ) )
    +			return urlencode( $description );
    +
    +		return get_the_title( $id );
    +	}
    +
     
     }
     
    

    Adam Bradford

    Director of Web Development at Highforge

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble