Title: Get template part name
Last modified: August 20, 2016

---

# Get template part name

 *  [dapis72](https://wordpress.org/support/users/dapis72/)
 * (@dapis72)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get-template-part-name/)
 * 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)

 *  [Tom Morton](https://wordpress.org/support/users/tm3909/)
 * (@tm3909)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get-template-part-name/#post-2223276)
 * Not tested, but try this:
 *     ```
       if ( (is_category('avtodomi')) || (is_page_template('loop1.php')) ) {
       ```
   
 *  Thread Starter [dapis72](https://wordpress.org/support/users/dapis72/)
 * (@dapis72)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get-template-part-name/#post-2223282)
 * 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???
 *  [Tom Morton](https://wordpress.org/support/users/tm3909/)
 * (@tm3909)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get-template-part-name/#post-2223283)
 * 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](https://wordpress.org/support/users/dapis72/)
 * (@dapis72)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get-template-part-name/#post-2223287)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [dapis72](https://wordpress.org/support/users/dapis72/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/get-template-part-name/#post-2223287)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
