WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] is_single Parameters (3 posts)

  1. Ryan Fitzer
    Member
    Posted 8 years ago #

    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.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    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.

  3. Ryan Fitzer
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic