Support » Fixing WordPress » possible to use is_page() for search?

  • Hi

    I want to show my code only on 2 pages. One is ‘products’ and the other one is ‘search’ (the default search page of wordpress).

    I Tried it like this:

    <?php if (is_page('products') || is_page('search') ) : ?>
    // do stuffs
    <?php endif; ?>

    I get it worked for the page ‘products’ but not for ‘search’.
    The URL of my search page would e.g. look like this: search/anything. In this case ‘anything’ would be the search keyword.

    Any way I could get this worked?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Thread Starter Raider000

    (@raider000)

    Thanks but this won’t work.
    I tried it with echo var_dump(is_search());
    On every page I get bool(false) but when I’m on the search page nothing appears.

    Moderator keesiemeijer

    (@keesiemeijer)

    The URL of my search page would e.g. look like this: search/anything. In this case ‘anything’ would be the search keyword.

    Are you using a plugin for the search results page. By default the url for search results is yoursite.com?s=anything

    Thread Starter Raider000

    (@raider000)

    No I’m not using any plugins. You can change the look of the permalinks on wordpress, so did I. But the URL stays basically the same, it just looks different.

    Moderator keesiemeijer

    (@keesiemeijer)

    You can change the look of the permalinks on wordpress, so did I.

    How did you do this? Did you create a custom page template for the search results?

    Try:
    – deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the default theme to rule out any theme-specific problems.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘possible to use is_page() for search?’ is closed to new replies.