Jump to content
zvelena

How to hook sharebar below page title? (not on blog posts or excerpts)

Recommended Posts

zvelena    0
zvelena

I want to add the sharebar below page titles on regular pages (not blog posts or excerpts).

I have found a great fix by @seanriceaz. I just changed 'pagelines_loop_after_excerpt' with 'pagelines_loop_above_content'

The code for functions.php is:


    //This function adds the pagelines sharebar to an excerpt (or really, anywhere)

	    function get_sharebar_in_excerpt(){

			    if (class_exists( 'PageLinesShareBar' ))

			    {

					    global $post;


					    $share = PageLinesShareBar::get_shares();

					    $meta_share = sprintf( '

%s

', $share );


					    echo $meta_share;

			    }

	    }


	    //Attach the sharebar function to the after post loop excerpt hook.

	    add_action('pagelines_loop_after_excerpt', 'get_sharebar_in_excerpt');

It works fine, however it is duplicating the sharebar on posts pages and excerpts, which are handled by default by the framework.

Any idea how I can add the sharebar under pagetitles on pages without duplicating them on posts pages ?

Thanks

Elena

Share this post


Link to post
Share on other sites
batman    389
batman

Hi Elena

You can hide Sharebar at Pageline Meta Setting to resolve the duplicating.

If you want add the sharebar under pagetittles on pages you can use this hook

'pagelines_loop_before_post_content'

You can add with Hook iFrames and javascript (provided by the companies themselves) they may be hard to style and control.


Life is too short to remove USB safely ...

Share this post


Link to post
Share on other sites
zvelena    0
zvelena

HI Batman.

Thx for the answer.

I dont have the sharebar section activated. It is not possible to pull it inside the content from the drag and drop menu. I want to use the sharebar that exists by default in metabar and usually shows on blog posts and excerpts under the title. I'd like to hook it under page titles (applies to any page or post, hence the duplicating).

If I deactivate the sharebar items from the Site options - Blog and Posts menu, the sharebar as a whole disappears from the blog posts and excerpts. I mention I am using the Pagelines Framework 2.5.5

Share this post


Link to post
Share on other sites
batman    389
batman

Hi zvelena

I´m a newbie, but you can try add this hook for sharebar under tittle


//This function adds the pagelines sharebar under tittle

function get_under_title(){

if (class_exists( 'PageLinesShareBar' ))

{

global $post;


$share = PageLinesShareBar::get_shares();

$meta_share = sprintf( '

%s

', $share );


echo $meta_share;

}

}


//Attach the sharebar function to the after post loop excerpt hook.

add_action('pagelines_loop_before_post_content', 'get_under_title');


Life is too short to remove USB safely ...

Share this post


Link to post
Share on other sites
Rob    547
Rob

Elena, as good as I am with hooks, this one's beyond me at the moment. However, I'm told "You can edit the section header and put the page template in there." Don't ask me what that means.

If you're going to edit a section, I'm sure you know to copy the section to Base Theme and edit the copied version. Don't edit core files.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Similar Content

    • arno
      By arno+
      The counter next to the icon in the Sharebar extension adds more mess than value for us. 
      Is there an easy way/code to hide the counter? (so that the icons line up closer?)
    • bnapoli
      By bnapoli+
      Is there an easy CSS fix to change the social media icons in Sharebar so they are colored, not just on hover?
    • MissT
      By MissT+
      Regarding the 'global option' mentioned by Simon in this previous post (to turn off the facebook opengraph data if you are using another plugin that provides it) ...where is this option? I don't seem to be able to find it.
      Many thanks in advance.
       
    • Grant Turck
      By Grant Turck+
      What file do I need to add code to in my pl-framework-pagelines child theme to insert script after opening body tag on every page?
      Can you someone provide me with the code also?
    • art23130
      By art23130+
      We had a very nice shortcodes library and hooker in the previous version of the platform. But in the version 5 they are missing. 
      So are you going to improve it again in future or no they are not supported anymore? 
      and one more question, what do you suggest for sharing bar which we had in DMS2 ?
      Thanks for your effort 
×