Archived topic
Add content after the first post's title in categories
3 replies · Started by Inverweb Spain, S.L. on March 21, 2017
Viewing posts 1–4 of 4
Hello,
I would like to add content only after the first post's title in categories, so I have the following code:
GP Hook: After Entry Title
<?php
if(is_category() /*&& post_index_within_loop == 0 */)
{
echo "my content";
}
?>
But I need some function to get the post index withing the loop, is there any hook to achieve it?
Regards
Hi there,
Not 100% sure it's possible, but if it is, this will be how to do it:
<?php
global $wp_query;
if ( 0 === $wp_query->current_post && is_category() ) {
echo 'My content';
}
?>
Yes, it worked! Thanks
You're welcome :)
This archived topic is closed to new replies.