I bet that you’re misunderstood what is_page_template
is really doing. From Codex:
This template tag allows you to determine if you are in a page
template. You can optionally provide a template name or array of
template names and then the check will be specific to that template.
And if you’ll take a look at it’s code:
function is_page_template( $template="" ) {
if ( ! is_singular() ) {
return false;
}
$page_template = get_page_template_slug( get_queried_object_id() );
...
… you’ll get, that you can’t use this function to target search results. It won’t work, because it’s meant to check if current page uses given page template. On the other hand you want to check if given file is currently used…
If your theme is coded correctly, then you should use is_search()
instead.
Related Posts:
- How do I add a search bar to my header?
- How can I make the wordpress editor apply the selected template?
- How do I style WordPress pages differently based on the tag used?
- CSS style button For WP Login Function in page template
- Conditional to determine if search.php page is the current template
- Video header on mobile, disappears behind header and content
- Conditionally print css style in WordPress
- Change the search icon in twenty fourteen
- Disable CSS for IE 8 and earlier.
- Highlight comments made by registered users of the site
- Why does this search.php not work?
- Problem alignment issue with echo knowledge base
- Style sidebar for a custom page template exclusively
- Text Not Wrapping Around Right Floated Image [closed]
- How to add input search field with roudned corners?
- CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page
- How to get these two divs side-by-side?
- What is the difference between the selectors “.class.class” and “.class .class”?
- Is background-color:none valid CSS?
- Text not wrapping inside a div element
- How to make padding:auto work in CSS?
- How to vertically center inside the parent element with CSS?
- How can I horizontally align my divs?
- background-size: cover not working?
- CSS not working in Chrome
- Pure CSS to make font-size responsive based on dynamic amount of characters
- CSS – display: none; not working
- How to enqueue style before style.css
- wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused
- What is the correct way to enqueue multiple CSS files?
- Which Details Are Required For Style.css File Header?
- How to implement different color schemes in your themes
- @font-face doesn’t work
- wp_enqueue_script + how to load JS or CSS in one URL merge call?
- How to target first img in every wordpress post with CSS [closed]
- How to change Parent Themes in Child Theme CSS
- hSite has no css on mobile [closed]
- How to set different font family based on text language?
- Relative path in wp_register_style not working
- Search Results: Differentiate posts and pages
- Enable specific CSS Code for Visitors and specific Roles
- WordPress on localhost working, when sharing IP to connect receive err_connection_refused on .js and .css files
- How to Add Custom CSS Buttons to WordPress as a Shortcode?
- Can’t remove WordPress post image height/width attributes?
- How do you customize the admin bar for buddypress?
- Load in wp admin assets from child theme
- Enqueue styles in new site editor in WordPress 5.9
- Two column Dropdown for WordPress Toolbar
- Change background color of subpages
- How to fix this error? [closed]
- Faster fonts on mobile
- Reduce white space in twenty fourteen
- How to make WordPress using local CSS/Fonts/Scripts only
- How to know which order WordPress places CSS files?
- Placing background image over section divider
- How to remove the gap on right side of webpage (using Bootstrap with WordPress)?
- WordPress CSS problems with controls
- Remove CSS & JS from
- Show class from css in format dropdown
- All of my custom Bootstrap styles are not working in my child theme!
- Aligning line made with CSS [closed]
- Earlier stylesheet not overriding later one
- Overwriting forced wordpress CSS styles [closed]
- How to add/insert a class to a sidebar in single.php?
- Sidebar missing from Homepage
- W3TotalCache and Javascript — what should go where, when?
- CSS not being applied
- Help with a little CSS logo/header modification?
- 2 css files? Theme css file gets override by another css file that I can not edit
- WordPress sidebar content moving to bottom of page
- custom template display 3 columns
- Does anyone know how to make text fade in when scrolling down, that doesn’t require any plug-ins? [duplicate]
- Inclution place of CSS file
- Blog page and the Home page showing the same content
- WP Admin Bar transparent on some pages (.screen-reader-shortcut)
- How to Compress Css/js code in wordpress and increase loading speed?
- More than one search results page template for two searches on site
- How to Take Logo Out of Navigation Menu? [closed]
- @media applying globally and not separately for each screen width [closed]
- How remove the white space between my menu and slider?
- WordPress site using unknown overriding css
- Header formatting works for safari but not chrome @media screen size technique on iphone
- Style Switching
- Adding a css style to the main nav menu in child pages
- Adding custom css to a theme depending on whether the admin user is logged in or not
- Adding CSS styles to Admin Area PAGES only (not POSTS or CPT)
- Diffrent search templates for different post types
- Adjusting post width according to the image size
- Converting Static HTML pages to WordPress
- Background tiles not working in iPad2 but ok everywhere else
- To override CSS of parent theme
- Can’t override CSS with child theme
- [class*=”content”]:before css styles in TwentyThirteen [closed]
- How to change the CSS in one file?
- Enqueue MCE Editor CSS in admin page
- How to avoid problems caused by new block-library default CSS rules (wp 6.1.1)
- Grid problem on privew mode
- Disabling double vertical scrollbar and horizontal scrolling?
- Customize margin between paragraphs using the Gutenberg Style editor
- How to remove automatically added custom style tag?