WordPress.org

Ready to get started?Download WordPress

Forums

If Home, Display Something, If Else, Display Something Else (6 posts)

  1. Connor Crosby
    Member
    Posted 2 years ago #

    I am making a WordPress theme and the homepage looks different than the rest of the pages. I want to use PHP to make it so if a user is on the homepage, it will display something. If they're on a different page, it will display something else. I am not the smartest person when it comes to PHP, so what could I do? Any help would be appreciated :)

  2. peredur
    Member
    Posted 2 years ago #

    Check out the WordPress Template Hierarchy.

    HTH

    PAE

  3. Connor Crosby
    Member
    Posted 2 years ago #

    Thanks, but I don't think that's what I am looking for.

  4. peredur
    Member
    Posted 2 years ago #

    Then could you explain what you do want? I think most of us would gather from what you've posted that you want a different template for your home page from your other pages.

    The other thing you might want, I guess, is to check whether the home page is being displayed or not... In which case you'd probably want to use conditional conditional tags. Which is how a choice of template is made, of course; but you can use them to just put conditional code in a single template, if you want.

    HTH

    PAE

  5. Connor Crosby
    Member
    Posted 2 years ago #

    Okay, sorry for the confusion. This is going to be put in the header.php file. I want to make it so if the homepage it being shown, a div container will be displayed. If it's not the homepage, then I want a different div container to be displayed. Thanks! :)

  6. peredur
    Member
    Posted 2 years ago #

    No problem. Sounds as though conditional tags are what you need.

    Cheers

    PAE

Topic Closed

This topic has been closed to new replies.

About this Topic