You can use this code once set page template for specific post. If the template isn’t set, you cant enqueue your script.
if ( $post->_wp_page_template === 'sky-template.php' ) {
wp_enqueue_script();
}
Remember to replace sky-template.php with your template file name.
Edit:
You can get some help from this question.
_wp_page_template to dynamically use template
Related Posts:
- Selecting An image from the Media LIbrary on the frontend
- Best practice – pages – ACF or inline coding
- How to hook up search results page to a back-end page?
- How to create “custom page types” with different custom fields in them?
- How to create custom layouts and static pages in themes for clients
- Creating custom page template
- wordpress custom posts page not showing
- Admin menu disable new/delete page
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Allow arbitrary text after page URL
- Best way to create a page outside of the pages list
- Custom single page based on which custom page template is selected
- How to apply styles to the custom page template
- Create a page for each database table entries
- How to use standalone Gutenberg (block editor) instance on any my own admin page in WordPress
- Block Theme: How to use a different template on front page vs paginated pages?
- How to structure model showcase
- Admin search post meta
- How can I have a common background color across multiple WordPress blocks?
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- How to customize
- Add a searchbox to the body of a page
- Is there a way to by-pass the pagination function on one custom template?
- Create page as a file in my theme?
- Customizing Users in Admin Area
- Data won’t save if metabox within conditional in admin. What am I missing?
- Featured Image If Else Condition
- Simplify the admin end
- What is the best way to modify Admin Panel on WordPress?
- Stop Expansion of Top Level Menu in the WordPress Admin Sidebar
- Insert menu with a custom walker into page / post body using shortcode?
- How to create custom search page
- Editing a post template
- WordPress archive index page
- Creating php pages in wordpress and assigning them to wordpress pages
- How to add custom meta box when you have a custom page template file
- How to display page ids as page slug names?
- How to add custom ‘layout’ buttons to wordpress editor?
- Custom Content Page
- How to make the Pages in WordPress Customized?
- Create a Page template selector page
- Force WordPress to load a specific template
- Change Site Logo or Menu Logo Per Page
- change top banner content on specific page
- How to add page content into another page
- Usage of custom post types in a custom admin menu
- Dynamic Sidebars based on page name
- Translate custom template with WPML
- How To make Custom page of every Category
- Display a specified content on a Page and all its child pages
- Created Custom Block – When I come back to edit post/page and change my block content – Update button stays disabled
- Custom default settings for WP native Gallery Block
- Select input in metabox not updated
- Will WordPress updates remove Gutenberg Additional Classes?
- Use a custom page with dynamic content as a user profile page
- why won’t my custom css load with the enqueue method or any other method?
- I want to embed mystream video in my wordpress site
- adding fade on mouseover to images
- Is it possible to edit a wordpress category with Gutenberg?
- Swap home page based on user role, Elementor layout breaking
- How to create custom backend admin menu in different languages?
- Taxonomy template is not reading
- Conflict between Yoast SEO and my custom theme
- New Page/Post Screen Opens an Existing Post
- Static Page, need Last and Next links at the bottom
- remove screenshot.png via dashboard
- How can I create a Custom Page? (not a page template!!)
- How to add a template – so that i can choose a different menu for some pages
- wp.blocks.registerBlockType not showing what I want on the frontend
- How can I delete the word `Category:` from page titles? [duplicate]
- How can I add category variable inside posts?
- Why does a custom php code inside a custom template not get executed?
- Put page on Archived statut after end of publication date
- POST 429 Error when trying to place more than 20 images into post at once
- Adding more than one WordPress Gutenburg block type?
- How do I target this page specifically?
- How to use a custom playlist template:
- How to serve an already coded html page in a WP page, to assign a simpler url
- Still desperate about multiple TinyMCEs in widgets – is there any good solution to this yet?
- Custom Admin Section
- Displaying Child Page’s Information
- how to hard link to the posts page?
- Getting a jQuery library to work in WordPress & Avada
- Show different pages on site depending on user choice
- Use another theme template in my theme
- WordPress post submit page
- Getting page/category content to show up in my custom page template
- Taxonomy template by post type
- Template setting is not saving in wordpress
- Adding pages to the Admin panel
- Customize Admin Section
- Make Terms Under Custom Taxonomy Use Specific Single.php Template
- Want home page to click through to two different page types
- How to duplicate “Pages” section in the control panel?
- Page template with custom html fields inside a content
- How to create functions that affect only a specific user
- Single page template
- Adding css and js to a blank page created with custom template
- Modifying a local template
- Create users via PHP