Hello,
I’d like to add custom HTML to certain post types before the content and after the content.
Is it possible to do that? I’ll need to specify which post type it is enabled on too.
What I am doing now is edited loop-index.php and manually added it to the code but it shows up for all posts. I have setup a custom post type which I want to hide the code for and show for the other.
Thanks.
Hi alvinhy!
You can use this function, https://codex.wordpress.org/Function_Reference/get_post_type, to check what post type the current post in the loop is.
Best regards,
Elliott
Hello Elliott,
Sorry but can you please let me know what code I should put in for that?
Say if I want to use code “<div>hello World</div>” and have it only show for only post type “articles” how would I type the code?
Best,
Alvin
Nevermind, I think I found a solution. I used:
if( get_post_type() == 'article' ) {
} else {
}