1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Position Of Social Sharing Buttons

Discussion in 'CSS' started by kertoon, Apr 22, 2015.

  1. #1
    Here is the code:
    // Add sharing button at the end of page/page content$content .= '<div class="crunchify-social">';$content .= '<h5>SHARE ON</h5> <a class="crunchify-link crunchify-twitter" href="'. $twitterURL .'" target="_blank">Twitter</a>';$content .= '<a class="crunchify-link crunchify-facebook" href="'.$facebookURL.'" target="_blank">Facebook</a>';$content .= '<a class="crunchify-link crunchify-googleplus" href="'.$googleURL.'" target="_blank">Google+</a>';$content .= '<a class="crunchify-link crunchify-buffer" href="'.$bufferURL.'" target="_blank">Buffer</a>';$content .= '</div>';
    return $content;
    }else{// if not post/page then don't include sharing buttonreturn $content;
    }
    };add_filter( 'the_content', 'crunchify_social_sharing_buttons');

    SEMrush
    By default the buttons are placed right after the content of each blog post. Now for certain posts, I would like to have the buttons somewhere among the blog content. How do I go about it?
     
    kertoon, Apr 22, 2015 IP
    SEMrush
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,375
    Likes Received:
    1,853
    Best Answers:
    245
    Trophy Points:
    515
    #2
    Well, for starters that code is just rubbish, no SERIOUS rubbish; attributes that have no business on any website any time after 1997 like TARGET, multiple string additions for no fathomable reason, PRETTY sure you're not going to be so far deeply nested a H5 is appropriate (are you REALLY sure that's a subsection of the h4 before it, is there even a h4 before it?!?), extra variable for nothing, endless pointless classes for nothing, no block level dividers so it would read as a run-on WORD "TwitterFacebookGoogle+Buffer", returning markup as a string instead of just sending it as output....

    That said "somewhere among the blog content" is pretty damned vague... what CMS are you using? what code is around whatever this is? Where is this being called from? what's the rest of the markup on the page? Would CSS positioning be able to move it where you want?

    You're really not giving a whole lot to work with.

    ASSUMING your blog topic is properly a h2 and guessing WILDLY, there is little reason for that code to be significantly different from:

    		return $content . '
    			<div class="socialLinks">
    				<h3>Share On</h3>
    				<ul>
    					<li class="twitter"><a href="' . $twitterURL . '">Twitter</a></li>
    					<li class="facebook"><a href="' . $facebookURL . '">Facebook</a></li>
    					<li class="googlePlus"><a href="' . $googleURL . '">Google+</a></li>
    					<li class="buffer"><a href="' . $bufferURL . '">Buffer</a></li>
    				</ul>
    			<!-- .socialLinks --></div>';
    	} else {
    		// if not post/page then don't include sharing buttonreturn $content;
    	}
    }
    
    add_filter( 'the_content', 'crunchify_social_sharing_buttons');
    Code (markup):
    Though depending on where and how it's called, I'd probably NOT be returning output and instead just echo the thing; particularly so one could make use of comma delimits instead of string addition for that extra hair of speed. (concepts lost on most of the halfwits using garbage off the shelf CMS or frameworks)

    As to moving it around, without seeing where it's placed in the rest of the code and/or the markup of the rest of the page, cannot say... though the 'logic' there seems flawed as if it's going to return content ANYWAYS (is that return on the comment supposed to be a separate line?) THEN just add it and have it work both ways.

    I also have no clue what this "crunchify" nonsense is, but it doesn't sound good.
     
    deathshadow, Apr 23, 2015 IP
  3. kertoon

    kertoon Well-Known Member

    Messages:
    155
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    133
    #3
    Well,......thanks.
     
    kertoon, Apr 24, 2015 IP