WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I wanted to show a slider on the home page only, is it better or does it make a difference if I:

  • use a PHP if/then statement and echo a division and markup, or
  • use CSS along with a body class and display none the division? or
  • a combination of both

What's the best practice?

share|improve this question
Conditional Tags is Good Option – Mohit Bumb Oct 3 '11 at 13:09
up vote 1 down vote accepted

target homepage only with if statement.

if ( is_front_page() or is_home() )


if your home page has page/2 page/3 then use the following to display the slider on only page 1 of the homepage.

if ( is_front_page() or is_home() && ! is_paged() ) {

share|improve this answer
Important to note, that I used or for a reason. It's more lightweight than || and && so the first one will be checked first and than compared to the result or ! is_paged(). – kaiser Aug 30 '12 at 12:51
if ( is_front_page() or is_home() )
    // Your Slider Code
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.