Archived topic
hook and php
3 replies · Started by Ignacio on August 31, 2018
Hi,
I added a shortcode to the After Content hook. I want it to be at the end of every blog post and it works well.
I have added:
<?php if ( is_single() ) : ?>
[shortocode]
<?php endif; ?>
The problem is that he shows it to me in other cpt. For example, the events generated by the Event Calendar plugin.
I have seen that is_single can be added id, title post...
But how can I make it only in the blog posts?
Regards
Hi there,
try the new Hooks Element:
https://docs.generatepress.com/article/hooks-element-overview/
You only need to add the shortcode, check the execute shortcode and then set the display location rules in this case > All Posts.
OMG !!!
How could I not have seen this!
Perfect, amazing, it's ideal.
Regards
haha, you must have been hiding somewhere :) Enjoy Elements, you will be writing a lot less PHP now. Check out the other articles for Header Elements and Layout Elements.