/**
* Filters list of page templates for a theme.
* @param string[] $post_templates Array of template header names keyed by the template file name.
* @param WP_Theme $this The theme object.
* @param WP_Post|null $post The post being edited, provided for context, or null.
* @param string $post_type Post type to get the templates for.
*/
add_filter('theme_templates', function($post_templates, $this, $post, $post_type){
// Unless post is 115, filter your custom template from the dropdown.
if(!empty($post) && $post->ID != '150'){
return array_filter($post_templates, function($template_name){
return $template_name !== 'your_template_name';
});
}
return $post_templates;
}, 20, 4);
Related Posts:
- Returning Variables back into a template
- Dequeue script in template isn’t working
- Adjust which tempalte a page uses with a function?
- Define PHP variable from a seperate API if statement
- Issues with title-tag and document_title_parts
- Is it ok to use a function to output the text domain name in a wordpress theme
- Define page template in wp_insert_post
- Display random categories on the front page (Finding and Editing Theme Functions)
- How to redirect to post if search results only returns one post
- Is it possible to stop selected plugins from loading on certain template pages?
- Add custom template page programmatically
- Define custom Page Template without its own .php file
- How to move page templates to custom folder?
- Create “File-less” Page Template in Functions.php
- How to get woocommerce inventory status [closed]
- How to override admin-bar style
- Is it possible to manipulate the list of page templates?
- TinyMCE custom styles remove class when switching styles
- Filter the query ONLY for the search results page
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- Check if a menu is empty?
- wp_get_attachment_image returns different image size
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Organize functions.php
- How to customize search result page title?
- How to override functions.php in child theme?
- Overriding core functions in child theme
- How to fix a theme with page.php Default Template that accidentally deleted?
- WordPress Change Post Templates,but not drop down, but Image selection
- Change parent theme file function in child themes functions.php
- Add inline css to theme
- Custom page template how to check is_page from functions.php?
- Dequeue Scripts and Style for Mobile not working?
- Using locate-template & shortcodes doesn’t appear to work
- Run Product Filter Javascript On Page Template
- Can I use require() function in a template file?
- Displaying Widgets
- How to set global variables in template page?
- Why isn’t is_page_template() adding a body class?
- Programmatically set page template based on page ID
- Query children and parent title
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- How to make unique add_filter to the_content of specific page template files – so each template gets its own addition
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- Switching between custom templates in a post type of the admin menu
- Add external js file to footer with id
- Changing itemprop from logo to image on custom logo?
- How to add background image control to page admin controls?
- Make “sidebar template” the default template for new pages
- How to specify which Gutenberg blocks are available in the editor for a page template
- Best Practice for Syncing Local Development With Staging Development [closed]
- how to change link of some wordpress pages
- Overwrite Parent Theme add_image_size in Child Theme
- Retrieve post modified date for specific post by post ID
- Show excerpt for only first post in query
- How to add css class to image attached in all the posts?
- Filtering posts by category name based on page’s slug
- Toggle Sidebar Display
- How to call custom function from functions.php in site-wide template files?
- How to use thumbnails in gallery?
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- Attach parent category template to all subcategories
- Add class or ID to any WordPress function
- Is there a way to add a class to non current menu item?
- Where can I access my custom page template?
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- Disable front-page.php template
- How to remove howdy dropdown menu content
- How to include local menu based on page id?
- How to create function from code?
- How to use Internationalized human_time_diff() function in Chinese?
- Display Password Protected external RSS in wordpress template
- is_dynamic_sidebar always returns true while using Jetpack visibility
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- is_account_page() change to page slug
- Selective Product Category for Carousel
- How to change login labels
- Activate small php condition at footer over page template
- Single Page theme [closed]
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Modify a function without editing template
- Can Page Templates be Applied to Archive and Post Templates?
- Retrieve tags data in post body
- Add caption functionality to custom WordPress theme
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Override a theme function in a child theme?
- Pulling Twitter RSS feed not working as expected (fatal error)
- Get_template_part inside a folder
- Use register_setting() in a loop
- Best practices regarding the creation of custom widgets?
- Add dynamic links in WordPress custom theme
- WordPress menu link doesn’t work properly
- Search filter by Post title OR Meta Title Value [duplicate]
- how can I edit flexslider in woocommerce. [Urgent]
- admin-ajax.php + load-scripts.php hanging for minutes
- Populate editor with some content of a page with a page template