Archived

This topic is now archived and is closed to further replies.

  • 0

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


Question

Posted · Report post

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

4 answers to this question

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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

Posted · Report post

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');

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites