Adding a section after the comment count on blog posts

Hi,

I’m wondering if there’s a way to somewhat easily add another section right after the comment count on blog posts. I have a plugin that adds the read time of blog posts and I previously had modified the single.php file in a different child theme but am now transitioning to BB theme. Is there an easier way to do it in the BB theme?

Here’s an image of where I’m hoping to add it:

https://drive.google.com/open?id=0B_csG2W4PjmsQlFFUW55Mm9KcHM

Also, is it possible to change the pipes to something else? They’re kind of large and I previously used a small dot which worked well.

Thanks for any help you can provide!

Hey Nick,

Welcome to the BB forums!

You will be able to hook into that section instead of editing your single.php. All you need to do is put code below in your functions.php this is in Appearance > Editor > Functions.php

function my_post_top_meta_close() {
    echo '<span class="fl-comments-popup-link"> | test</span>'; 
} 
add_action( 'fl_post_top_meta_close', 'my_post_top_meta_close' );

Replace ‘test’ with any content you wish. Check out this page for more info on which aspects in the theme you can hook into and what action reference to use.

Jun

Awesome, thanks Jun. I got the hook in there and it worked, but is there a way to change the divider so rather than a | it’s a ∙ or something like that?

The page with all the places I can hook is definitely invaluable.

Hey Nick,

Glad to hear you were able to get it to work! Re the separator, there’s currently no way for us to filter into that but we can use CSS. What we need to do is hide the current separator using display:none like so

span.fl-sep {
    display: none;
}

Then we replace that using the ‘Content’ property with your own separator, in this case, I’m using a hyphen-:

div.fl-post-meta > span+span:before {
    content: " - ";
}

Jun

Thanks Jun, good solution. That did just the trick and I was able to add a bit more CSS to customize it a little further. Perfect.

Hi Nick,

Happy to hear your issue has been resolved and thanks for informing us.

Thanks,
Danny

That did the trick but now I saw something else after looking at it from the main blog page.

The hook also puts it into the main blog page and also any category/archive pages which it doesn’t work properly in because it can’t calculate the read time properly.

Is it possible to set this hook to only work on the blog post itself?

I’m assuming it needs something like && !is_blog_post() but I know that’s not formatted correct and no idea where it would go :slight_smile: My php is a bit rudimentary.

function my_post_top_meta_close() {
    echo do_shortcode ( '<span class="fl-sep"> | </span><span class="fl-read-time"> text</span>' ); 
} 
add_action( 'fl_post_top_meta_close', 'my_post_top_meta_close' );

Hi Nick,

Can you replace the previous snippet provided by Jun with the following, please.

function my_post_top_meta_close() {
  if (is_single()) {
    echo '<span class="fl-comments-popup-link"> | test</span>';
  }
}
add_action( 'fl_post_top_meta_close', 'my_post_top_meta_close' );

This should then display test on single posts.

Thanks,
Danny

Yes, this worked great, would have never figured that out by myself.

Thank you.

No problem, Nick.

Happy to hear your issue has been resolved and thanks for informing us. We appreciate it.

Thanks,
Danny