Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #483829

    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.

    #484033

    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

    #484114

    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

    #484173

    Nevermind, I think I found a solution. I used:

    			if( get_post_type() == 'article' ) {
    			} else {
       	 
    			}
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Add html before and after content’ is closed to new replies.