WordPress.org

Ready to get started?Download WordPress

Forums

How to make things only appear on posts? (3 posts)

  1. klippert
    Member
    Posted 1 year ago #

    Hi, I am trying to figure out how to make things only appear on my posts and not my homepage. I use an index.html template for both the homepage and my posts. I have this code <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?> to make some stuff appear just on my homepage, but i would like to know if there is an opposite to that that makes things only appear on posts.

  2. catacaustic
    Member
    Posted 1 year ago #

    If you want it so that it's not showing on the home page:

    if (!is_home() && !is_front_page()) {
        // Your code in here
    }

    is_home() and is_front_page() are slightly different, but you should use both of them to check properly.

    Another thing that you can do is use an if/else statement with what you have now:

    if(is_home() && $post==$posts[0] && !is_paged()) {
        // Post page
    }
    else {
        // Home page!
    }
  3. alchymyth
    Forum Moderator
    Posted 1 year ago #

    is_single() would detect single posts;

    http://codex.wordpress.org/Conditional_Tags

Topic Closed

This topic has been closed to new replies.

About this Topic