WordPress.org

Ready to get started?Download WordPress

Forums

HTML code only for a specific Post ID (5 posts)

  1. Alkorr
    Member
    Posted 2 years ago #

    Hi, I would like to add (or remove) some HTML code but only for a specific Post ID.

    So if the post I'm viewing has this specific ID (say 234), then on my single.php page, I will add some new HTML code that will not show when I'm viewing any other post.

    I searched but couldn't find a way to do it... Your help is welcome! :)

  2. Troy Chaplin
    Member
    Posted 2 years ago #

    Take a look at WordPress conditionals. You can add a conditional on your single.php file for single pages based on an ID like this:

    <?php if ( is_single( '234' ) ) { ?>
        <!-- you text or code -->
    <?php } ?>
  3. raskull
    Member
    Posted 2 years ago #

    Take a look at post formats: http://codex.wordpress.org/Post_Formats

  4. Alkorr
    Member
    Posted 2 years ago #

    Hi Troy, thanks a lot, your code works like a charm! :)

    Thanks Raskull, I didn't know this page of the Codex.

    Could I dare ask for such a short code but not for a specific post ID but if I'm viewing the latest post (the most recent post published)?

    Thanks again!

  5. Alkorr
    Member
    Posted 2 years ago #

    I try is_current but it does'n t work either...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags