Using beans_post_meta() in creating custom posts page

I'm trying to make a custom layout for the posts page (a blog). So I created home.php in my child theme and entered the below.

// builds post with trimmed excerpt
function blog_post_excerpt( $content ) {

    $post_meta = ob_get_contents();

    $post_excerpt = '<p style="font-size: 14px; line-height: 20px;">' . wp_trim_words( $content, 40, ' ... ' ) . '</p>';

    return $post_meta . $post_excerpt . beans_post_more_link();


add_filter( 'the_content', 'blog_post_excerpt' );


This works, but I can't shake the feeling that it's more complicated than it has to be. I use output buffering to prevent beans_post_meta() from echo'ing the meta at the top of the document, which is will otherwise do. Is there another way around this?

I did not include the title because it seems that Beans will include this anyway.

A distant, secondary concern... The inline styling for the tag is to escape the .uk-text-large class, which is added to post excerpt automatically. Again, this works but it's kind of ham fisted. Any thoughts?

Hi Kevin,

You are correct to say that it isn't really elegant to do so, even though it works. Instead you should use Beans hooks to prepend the post meta in the content tag (so that it is right before the content). To do that , you may simple add the following line in your home.php.

beans_modify_action_hook( 'beans_post_meta', 'beans_post_content_prepend_markup' );

Regarding the uk-text-large class, this is not done in Beans Core but I am confident that I can help you removing it in an elegant way too πŸ™‚ Are you perhaps using a child theme or did you add a snippet from somewhere on the very wide wild web?


This is a bit embarassing but both issues are with the functions.php of the child theme, Totem. There's a line beans_remove_action( 'beans_post_meta' );. Just comment this out and I don't have to do anything with the post meta; it displays as you would expect it to normally.

As for uk-text-large, this was being added to various <article> tags. I added beans_remove_attribute( 'beans_post_content', 'class', 'uk-text-large' ); to home.php.

So I suppose that the takeaway is that if you're building on someone else's foundation and something unexpected is happening (or not happening), check functions.php first.

Hi Kevin,

There is nothing embarassing about it, in fact Chris did that on purpose in Totem. This is partly why Beans is so powerful, Chris designed a child theme without post meta and it took one line to remove it πŸ˜‰

Just a quick reminder, child themes are meant to be a starting point and since there is no update for it, you can do your modifications straight in your child theme and continue building on it. So you can freely remove beans_remove_action( 'beans_post_meta' ); in your child theme and remove the uk-text-large class directly in there.

Have fun,

Write a reply

Login or register to write a reply, it's free!