Site logo

Archived topic

Adding content on blog archive page using generate_footer_entry_meta_items

6 replies · Started by Switch on June 7, 2021

Viewing posts 1–7 of 7

Hi!

I would like to add a small block of code right after the categories meta. I don't want to re-order the items or remove anything, just to add a block of code like the one shown below:

<div class="foo-text">Foo</div>

How could I achieve this using the generate_footer_entry_meta_items filter?

Thanks in advance!

Hi there,

you can use the generate_after_content hook which will appear immediately after the footer.entry-meta container.

Thank you so much! That worked great!

For future reference, may I ask why the filter wouldn't have worked better?

For sure... that filter only sets the display conditions for a pre defined array of $items - see here:

https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/post-meta.php#L383-L392

The $items are first registered with using the generate_do_post_meta_item

https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/post-meta.php#L164

Which you can hook into using the generate_post_meta_items action hook:

https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/post-meta.php#L292

Tom provides an example for adding an $item ( in this case a reading time function ) to the meta_items and then filtering it into the meta ( although in this case its the header entry meta):

https://generatepress.com/forums/topic/post-visit-counter-and-mins-read-time/page/2/#post-1586449

All in all - it involves a lot more steps :)

Perfect, thanks :) !

Resolved 🎉

You're welcome

This archived topic is closed to new replies.