Use the page-specific meta box hook & accept the $post
object that’s passed to it – then you can check if it currently has a page template of sky-template.php
.
add_action( 'add_meta_boxes_page', function ( $post ) {
if ( $post->_wp_page_template === 'sky-template.php' ) {
add_meta_box( 'sky_page_excerpt', 'SkyScraper Page Excerpt and Links', 'sky_page_excerpts', 'page', 'advanced', 'high' );
}
});
Note: this will only work on submit/refresh i.e. when you first (de)select the template when editing, you’ll need to save changes and have the page reload for the meta box to take affect.
Related Posts:
- Need help with adding templates (archives and sitemap) to WordPress child theme
- Is it possible to manipulate the list of page templates?
- Do I really need the div class entry?
- Where can I access my custom page template?
- Highest number of WordPress Custom Page Templates?
- How to create a custom page(not a template) in a theme
- how to setup custom content structures
- Issue On Displaying Pages with Post Name Permalink
- Why in the static pages of my theme are showing these information?
- How to add pages in wordpress using codes?
- Injecting pre-defined text from custom page template to editor
- Custom theme template files
- Problem with Displaying Custom Theme Page’s Content
- How to show children pages as array
- Why WordPress gets old templates code instead of the last updated ones
- Can you create a custom page with content in the center already defined?
- Standard Way To Do Custom Work Within A Page?
- How to use shortcode inside of shortcode in theme
- Converting a theme to a child theme in a network
- Trouble in creating a custom template on twentyeleven theme
- Parent/Child pages
- How to modify theme content in Thematic?
- Understrap-child conditional js script
- Custom search template is showing 404 when adding query string
- ACF get_sub_field ALT TAG in the repeater doesn’t show
- WordPress Animation Adjustments
- Show only pages you are author of
- How do I open a post in a custom page in wordpress?
- A Reviews Page is Showing root Index.php instead of Template-Page
- No templates for condition page.php Elementor
- Why front-page.php doesn’t show content of file instead shows loop
- Theme functions don’t work as expected in partial included via get_template_part() after custom query using Ajax [duplicate]
- Copying a modified theme from one wordpress site to another wordpress site [closed]
- How can I access variables from theme in child theme? [closed]
- How to display home page last modified date in anywhere of wordpress theme?
- Show Yoast SEO meta tags in Custom WordPress Templates (Theme)
- What is an alternative to not using child theme to customize a WordPress theme?
- Block validation failed for `core/pullquote` after adding theme support for editor-color-palette
- Where i must put hooks in overridable functions?
- Pages not displaying as sections on static page
- Is_single not working properly in genesis
- (Parent) theme Is Not Showing In Theme Selection Panel and Therefore Breaks Child Theme
- Child theme menu not appearing in Twenty Seventeen
- makeing a terms of use page that is part of the theme
- Edit Product Archive design for Woo theme
- How can I fix my theme header for my CSS stylesheet?
- How to test another theme in a live WordPress website instead of live preview?
- Template for front page (latest posts)
- Duplicate child theme incl. design changes
- Move the social media icons to the left of a WordPress nav menu for Soledad child Theme
- Creating a theme just to deploy a single page
- How to connect two child themes on different sub domains to the same base theme
- Debugging slow WordPress Theme Customizer (Any option similar to Query Monitor)?
- Group several custom global page templates in sub-folder
- Editing Them with Child Theme Basics [closed]
- How to customize the colors within a stylesheet using a WordPress setting
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Child theme in separate WordPress Install
- Change header image on a particular page
- Alter theme pages on language switch
- wp_editor some functionality not working on custom theme
- Update modified Shopify third-party theme [closed]
- how can I re-utilize and class on a child theme
- Providing updates to your WordPress theme
- Different stylesheet for different pages not working fully
- Display content on Single page
- One-Page WordPress Template
- Create a custom theme-specific page, invisible in the admin-panel?
- Hook in parent theme Menu function
- Create a variable with string, array or multiple values
- How to create multiple pages in a client theme?
- How do child themes work?
- How can I display and excerpt of all pages with a meta_key and meta_value on index.php?
- Protecting work on client’s web host
- Advantages/Disadvantages Using Theme Editor Instead of Pages
- How to migrate the menu from the site on my own theme in WordPress?
- how to make a new page affected by a theme’s index.php layout?
- How get the 10 most viewed pages (not post)
- How can I change the title of the Home link in the navigation bar?
- adding navigation to genesis themes
- Extending arrays in parent theme without completely overriding the files
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- The content not wrapped in paragraph tags with get_page_by_title()
- Loop inside page template not working
- WordPress theme Modifications not showing up on live server
- How do I get information about a page, such as featured image, except, and title?
- What to do when child theme is out of date with parent theme
- Extracting Distance from FacetWP Proximity Function to Display in WordPress Template
- add_action works outside condition but not inside it
- Global Navigation menu in diiferrent wordpress setups
- Image Size wrong during upload
- Is there any way to show child theme in theme detectors?
- Should I create a child theme for a parent custom theme? [closed]
- How can i display a 4 diferent themplate for the archive page
- How to split the site’s layout without damaging this layout? [closed]
- I’m new in developing responsive WordPress Theme, so which framework to use or work from scratch? [closed]
- Twenty sixteen – full height
- DIV containing iframe disappears below break point of 992 in Oxygen Builder
- ways to create customized theme (hard coded – no pagebuilder)
- Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?