• Hello

    I am making custom sidebar with WP Custom Search. Each category would have separetecustom search. So when i choose category page my if sentence works, but when i make search custom search change. So page is calling template_part search, and i would like to include that in my if sentense.

    Code:

    <?php
    if (is_category('avtodomi') || is_page_template('loop1.php')) {
    	$preset='preset-2';
    }
    else {
    	$preset='default';
    }
    ?>

    Thanks a lot to all for help.

    [Please post code snippets between backticks or use the code button.]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Not tested, but try this:

    if ( (is_category('avtodomi')) || (is_page_template('loop1.php')) ) {
    Thread Starter dapis72

    (@dapis72)

    Thank you for replay, but no difference. I don’t know how to get ID or whatever of search page. Maybe the problem is causing by template parts???

    Maybe I’m misunderstanding your need. Are you trying to see if the current page is the search page? Or are you on the search page trying to define something with if/else statements?

    Thread Starter dapis72

    (@dapis72)

    Ok I know my english is not good enaugh, but let me try again. I have categories like cars, bike, etc. On category page cars i wanna have sidebar with custom search for cars, on category page bike…custom search bike. And now this if works. Next, for example i am on category page cars. When i make search….i get results OK, but my sidebar is not any more from the category page cars. So i wanna somehow make filter whenever i am on category page or search result, the sidebar has to be from the “original” template, in this case cars. Still complicated?

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

The topic ‘Get template part name’ is closed to new replies.