Jump to content
Sign in to follow this  
peterb

Add hook at the end of post

Recommended Posts

peterb

I want to insert a signature at the end of each blog post, before social icons, related posts and all that. The code I was told to use in order to implement a signature was as follows: <?php the_content(); ?> <?php if (is_single()) { echo '

"Signature text here"
'; } ?> I'm using a plugin now to display the signature, but it appears between social icons and YARPP, which doesn't appeal to me.

Share this post


Link to post
Share on other sites
Simon
Please take a look at the 1st search result: http://www.pagelines.com/forum/discussion/9740/custom-signature/p1

Share this post


Link to post
Share on other sites
peterb
Thank you for your response but that didn't do it. Not displaying correctly. Now being displayed below my current signature, which is below the social icons, and also on all pages (not just single posts).

Share this post


Link to post
Share on other sites
Rob
May we have a link to your site?

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
peterb
Sure thing: http://einstein.is I figured the code would go something like this (let it known that I'm very inexperienced in this, so this could be dead wrong): [code]add_filter('pagelines_"HOOKPLACEMENT"','signature'); function signature($text) { global $post; if($post->post_type == 'post') && is_single() ) { $text .= '
MY SIGNATURE
'; return $text; }[/code]

Share this post


Link to post
Share on other sites
peterb
Something in that fashion. By trial and error I have managed to get the code by displaying only on single posts by inserting the following code into functions.php: [code]add_filter('the_content','add_signature'); function add_signature($text) { global $post; if($post->post_type == 'post' && is_single() ) $text .= '
TEXT
'; return $text; }[/code] So all that's left now is figuring out how to insert the text at the end of the post_content.

Share this post


Link to post
Share on other sites
Simon
try this: [code]add_filter('the_content','add_signature' , 999);[/code]

Share this post


Link to post
Share on other sites
peterb
Thank you for that suggestion, but no change. Still appears below the post if I use: [code]add_filter('the_content','add_signature' , 999);[/code] instead of [code]add_filter('the_content','add_signature');[/code]

Share this post


Link to post
Share on other sites
Simon
your probably better off using an action rather than a filter. 'pagelines_before_sharebar' would be a good candidate. You can install the action map plugin to see where they all happen. [code]add_filter('the_content','add_peters_signature'); function add_peters_signature($text) { $sig = ' sig in here! '; printf( '
%s
', $sig ); }[/code]

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

Sign in to follow this  

×