• 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

Social Media Share Buttons Help

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 › Social Media Share Buttons Help

This topic is: resolved

Tagged: css, functions.php, social media

  • This topic has 4 replies, 2 voices, and was last updated 7 years, 8 months ago by itzsnider.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • May 27, 2015 at 1:04 pm #153854
    itzsnider
    Participant

    All,

    I am trying to add a set of my own buttons under the 1st paragraph in Parallax Pro.

    I have accomplished it with a shortcode but can't figure out how to make it happen without crashing the site.

    function ads_added_above_last_p($text) {
    	if( is_single() ) :
    		$ads_text = '<div class="a" style="text-align: center;">[PUT SHORTCODE HERE]</div>';
    	if($pos1 = strpos($text, '<p>', strpos($text, '<p>') + 3)){
    			$text1 = substr($text, 0, $pos1);
    			$text2 = substr($text, $pos1);
    			$text = $text1 . $ads_text . $text2;
    		}
    	endif;
    	return $text;
    	}
    add_filter('the_content', 'ads_added_above_last_p');

    The above is the code to make it work - you can put anything, ads etc where it says [PUT SHORTCODE HERE]

    BUT, what I want to do is add the following to the site now.

    Here is the code I use in the widget now to show "after entry".

    <div class="opt-social_vertical-column vertical-column-top">
        
            <a class="opt-social_vertical-column_link facebook" href="https://www.facebook.com/sharer/sharer.php" onclick="var sharerFb = 'https://www.facebook.com/sharer/sharer.php?u='; window.open(sharerFb + location.href, 'sharerFb', 'width=626,height=436'); return false;">Share</a>
    <a class="opt-social_vertical-column_link twitter" href="https://twitter.com/share" onclick="var sharerTw = 'https://twitter.com/share?url='; window.open(sharerTw + location.href, 'sharerTw', 'width=550,height=520'); return false;">Tweet</a>
        
    </div>

    When I replace <div class="a" style="text-align: center;">[PUT SHORTCODE HERE]</div> with the above, it crashes the functions.php.

    What the heck am I missing here?

    http://www.geekdaily.co
    May 27, 2015 at 2:23 pm #153861
    Sridhar Katakam
    Participant

    Try this:

    function ads_added_above_last_p( $text ) {
    	if( is_single() ) :
    		$ads_text = '<div class="a" style="text-align: center;"><div class="opt-social_vertical-column vertical-column-top">
    	<a class="opt-social_vertical-column_link facebook" href="https://www.facebook.com/sharer/sharer.php" onclick="var sharerFb = \'https://www.facebook.com/sharer/sharer.php?u=\'; window.open(sharerFb + location.href, \'sharerFb\', \'width=626,height=436\'); return false;">Share</a>
    	<a class="opt-social_vertical-column_link twitter" href="https://twitter.com/share" onclick="var sharerTw = \'https://twitter.com/share?url=\'; window.open(sharerTw + location.href, \'sharerTw\', \'width=550,height=520\'); return false;">Tweet</a>
    </div></div>';
    		if( $pos1 = strpos( $text, '<p>', strpos( $text, '<p>' ) + 3 ) ){
    			$text1 = substr( $text, 0, $pos1 );
    			$text2 = substr( $text, $pos1 );
    			$text = $text1 . $ads_text . $text2;
    		}
    	endif;
    	return $text;
    }
    add_filter( 'the_content', 'ads_added_above_last_p' );

    Genesis Tutorials | Follow me on Twitter

    May 27, 2015 at 4:05 pm #153872
    itzsnider
    Participant

    What am I missing?

    I am trying to add the rest of the code -

        <a class="opt-social_vertical-column_link google" href="https://plus.google.com/share" onclick="var sharerGp = 'https://plus.google.com/share?url='; window.open(sharerGp + location.href, 'sharerGp', 'width=840,height=464'); return false;">+1</a>
        <a class="opt-social_vertical-column_link reddit" href="http://www.reddit.com/submit" onclick="var sharerRd = 'http://www.reddit.com/submit?url='; window.open(sharerRd + location.href, 'sharerRd', 'width=840,height=464'); return false;">Submit</a>
    May 28, 2015 at 6:44 am #153949
    itzsnider
    Participant

    Did a html to php convertor and this is what I added

    still crashes it!

    <a class="opt-social_vertical-column_link google" href="https://plus.google.com/share" onclick="var sharerGp = \'https://plus.google.com/share?url=\'; window.open(sharerGp + location.href, \'sharerGp\', \'width=840,height=464\'); return false;">+1</a>
        <a class="opt-social_vertical-column_link reddit" href="http://www.reddit.com/submit" onclick="var sharerRd = \'http://www.reddit.com/submit?url=\'; window.open(sharerRd + location.href, \'sharerRd\', \'width=840,height=464\'); return false;">Submit</a>';
    
    May 28, 2015 at 6:55 am #153950
    itzsnider
    Participant

    GOT IT!

    damn ;

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 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