Your first version of no_sidebar_style()
looks fine:
function no_sidebar_style(){
if (is_page_template('page-templates/page-nosidebar.php')) {
wp_enqueue_style( 'no-sidebar-style', get_stylesheet_directory_uri().'/css/no-sidebar.css');
}
}
add_action( 'wp_enqueue_scripts', 'no_sidebar_style', 19);
For debugging, you can use get_page_template()
to see the name of the template you’re viewing.
Related Posts:
- Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?
- Use [embed] filter in template files
- How to force TinyMCE in WordPress to replace newlines with tags and not with
- WooCommerce: Change template for single product page
- How to show a under construction page for a domain but still be able to work on index.php?
- Echoing Elementor page content in template, but it doesn’t get styles and some widgets are missing
- Gravity Forms Custom Templates [closed]
- add/apend templates ‘transparently’ via plugin to currently active theme or child theme?
- Programmatically change post templates?
- Gutenberg Editor – Template Doesn’t Match Error
- Need to give custom page template for each language in WPML
- TwentyTen: Overloading template.php files vs. get_template_part
- Post formats template
- Proper way to use get_the_content() in front-page.php and the content-home.php?
- Using “setup_postdata” with “get_template_part” does not work
- What is a good way to present templated content in WordPress?
- Load template file without a post type
- How to display error on specific template?
- Plugin settings page template
- How do you override Post template when using Query Loop block?
- Auto-Generate Longtail-SEO Pages/URLs
- Strange Behaviour with is_home()
- bloginfo(‘template_directory’) img src
- Should template files be copied to the child theme for editing?
- How to create a wordpress template without using any page
- Change location of header.php and footer.php
- Routing dynamic numeric slug to custom template
- Is there any way of viewing revision history on files in WordPress?
- How to use $wpdb (from the template) to update the DB, without being an admin
- Customize profile.php
- Change wp-signup.php Page Template
- Templates have disappeared from drop down lists
- Getting pages filtered by template assigned
- Use same page template for parent and child pages in a theme
- Template administration Error after WP 4.8 update
- Markup is visible when I view sample data from my template
- if page is parent page redirect to first child with hook / polylang
- Custom template bypassing to pager to index.php
- Remove Items from Template Homepage
- How to put limit on slider
- What are the main parts of a WordPress Template?
- Using shortcode in template file
- Page template option missing
- Trying to create a template without navigation and footer
- Genesis – Adding custom hooks to display secondary navigation
- Remove portion of header code from home page only
- Force WordPress to NOT display the manual excerpt
- Can I assign a Folder for Post Formats, without it affecting WordPress’ fallback/hierarchical system?
- Custom Template page not loading get_header() correct?
- Easiest way to map content (in json) to the view (template)?
- Removing calls to noindex() and wp_no_robots()
- Query the database after get_header() has been included
- Give wp link pages it’s own template
- Does wp_mail work in frontend tempate file?
- Dynamically generated URL and Content page
- Organize template parts and page templates in folders in regards of template hierarchy
- Need help with my template [closed]
- Custom /Page/2/ Template Only
- wordpress – modifying template to show more posts
- How to get all template files used for rendering a single post/page?
- How to insert “get_template_part()” based on Category ID?
- How does post loop integrate individual page elements
- Home page not loading after editing header.php file
- How can I include ALL post types in the_post_navigation() links, not just current post type?
- Template includes
- Two different single.php depending on source page
- Attachment URL for an image is loading direct image file
- Fixing media query
- I’ve installed example data on Nominee template but the published site shows another version of the site
- Using a SendGrid transactional template with wp_mail
- Set og:image programmatically in custom single post with external images
- Displaying all posts of a category in full view on one page using their single.php template
- why does not showing my custom post category list in any template?
- Locating the HTML piece of code in wordpress
- Custom Template doesn’t output result when set as homepage
- Theme keeps going to default files [closed]
- How can I show contents of a template part inside of another page?
- How to serve a amp template
- Single page applications with WordPress: routes and templates
- Inserting javascript file into theme template?
- Creating custom post-listing templates in twentyseventeen child theme
- Creating page-templates directory breaks everything!
- Editing the tag pages and using templates
- Creating a popup
- Category template not displaying all post formats
- Problem displaying replies as part of author’s latest comments on author page
- custom template – override plugin template in child theme – issue with scripts
- Is it better practice to create many page templates, or a a few base templates with custom HTML added via TinyMCE?
- Add pagination to blog
- Mysterious template change after database import/export
- Choose to show or not show title on a template?
- Add multiple pages to theme customizer
- Single Post Template with Dropdown Option?
- Single template will not show sidebar/bottom-nav and footer
- Output fields manually in Woocommerce email templates
- Templates to use multiple time within page? [closed]
- Custom template pagination
- My homepage’s width has reduced and I can´t fix it [closed]
- templates page not showing on gutenberg editor
- How to load php templates from html page (block theme)