0

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?

1
  • Conditional Tags is Good Option
    – Mohit Bumb
    Commented Oct 3, 2011 at 13:09

2 Answers 2

1

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() ) {

}
1
  • 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
    Commented Aug 30, 2012 at 12:51
0
if ( is_front_page() or is_home() )
{
    // Your Slider Code
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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