Archived topic
Hook after_content outside article
5 replies · Started by Philippe on June 16, 2020
Hi, I want to use this code:
<?php
global $wp_query;
if ($wp_query->current_post == 4) {
echo "AD";
}
?>
With after_content hook to show an ad after the 5th post in archives.
It works, but I would like to have it outside the <article> so it's not inside the box, but between the boxes. There is a hook or way to achieve that?
Thanks.
Hi there,
As of right now there is no hook there, so you'd need to alter the templates in a child theme.
In 2.5.0, we've implemented a hook system for the content parts so this will be possible without altering files.
Thanks for the quick reply.
2.5.0 is in beta stage? That sounds good!
Regarding child theme, there is a way to do it with the Code Snippets plugin?
If not, I've seen that you recommend an ad inserter plugin. However, the ones I've tested use jQuery and I can't use it because my site has AMP. Do you know of a plugin that can do this without using extra Javascript?
If not, I will go with the child theme route. What happens with it if there is a theme update?
Thanks again.
2.5.0 is still in development, so not quite in alpha yet.
You can use a child theme, you'll just want to watch when 2.5.0 is released and update the file/scrap it and use the hook method.
Thanks, I was able to do it with the child theme :)
Awesome :)