the_post action not working
-
Hello! I’m pretty new to the inner workings of wordpress and I’m having a problem trying to get a function to display in my custom post type.
Ideally, I’d like to have a bit of html automatically added to the front end of my custom post type every time I publish a new one.
from what I understand, putting this in my child theme’s functions.php should have done it:
add_action( 'the_post', 'teaching_part_one' ); function teaching_part_one(){ ?> <p>custom code</p> <?php }
but when I put that in and update it, it will display
“custom code custom code
custom code custom code
custom code custom code”
etc…in the header of every page on my site, which confuses me, because I thought that would hook into (not sure if i’m using that correctly) the posts on my site.
Would anybody know what I might be doing wrong, and how I might be able to add code that will display in all of my posts automatically, preferably to the child theme?
thanks for reading my post, and thank you in advance for the help!
- The topic ‘the_post action not working’ is closed to new replies.