• Resolved drinkingsouls

    (@drinkingsouls)


    Hey guys,
    I’m using conditional statements in my theme. I’m trying to check if it is not a home page or a single post.

    if (!is_home()) Works great to say if it is not the home page.

    I tried if (!is_home() || !is_single()) but I can’t get that to work. I need to say if it is not the home page or a single post.
    Any ideas?
    Any help is appreciated.
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • You want to use:
    if ( !is_home() && !is_single() )

    Moderator keesiemeijer

    (@keesiemeijer)

    the “!” part means “not”.
    so try this:
    if (!is_home() || is_single())
    This means: if it’s not the home page or if it’s a single post.

    Memories of my college logic course!
    Are you testing that it is not a home page and it is not a single post?
    The coding becomes clearer when you first word it that way.
    Being a newcomer to WP, templates, html and PHP I don’t know those coding conventions but that’s how I approached that logic in earlier languages.

    Thread Starter drinkingsouls

    (@drinkingsouls)

    Thanks a ton Curtiss Grymala, that was it.
    Just to clear it up, yes I’m testing that it is not the home page and not a single post. The code that worked it:
    if ( !is_home() && !is_single() )

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Double Conditional Statement’ is closed to new replies.