• Resolved Ryan Fitzer

    (@ryanfitzer)


    Does anyone know the parameters for is_single()? Specifically, I need to know if I can pass a specific category into it.

    For example:

    if (is_single(cat=1)) {
    echo "<div id="slides"></div>";

    I need to differentiate my header based on categories and it’s working for the most part except when it’s on a single post. Thanks for the help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    No, you can’t pass a category into it. You can pass the post’s ID, title, or name and see if you’re on the page with just that particular post.

    I assume you want to check if the post you’re currently displaying is in some given category, right? What you really want to use is in_category, then. It takes a category ID as the parameter and returns true if the post is in that category.

    While you normally have to use it inside the loop, that page on the codex shows you how to use it outside the loop as well. That particular method will work for the first post on the page only, but since it’s a single page, then that should work just fine for you.

    Thread Starter Ryan Fitzer

    (@ryanfitzer)

    That was it! Thanks. My problem was I was using is_category.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘is_single Parameters’ is closed to new replies.