/**
* 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
- Is it ok to use a function to output the text domain name in a wordpress theme
- Define page template in wp_insert_post
- 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?
- Define custom Page Template without its own .php file
- How to move page templates to custom folder?
- How to override admin-bar style
- Is it possible to manipulate the list of page templates?
- TinyMCE custom styles remove class when switching styles
- 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
- 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
- Dequeue Scripts and Style for Mobile not working?
- Using locate-template & shortcodes doesn’t appear to work
- Run Product Filter Javascript On Page Template
- 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
- How to make unique add_filter to the_content of specific page template files – so each template gets its own addition
- Switching between custom templates in a post type of the admin menu
- Best Practice for Syncing Local Development With Staging Development [closed]
- Overwrite Parent Theme add_image_size in Child Theme
- Filtering posts by category name based on page’s slug
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- 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?
- is_dynamic_sidebar always returns true while using Jetpack visibility
- Default Gallery Edit/Template Editable?
- Activate small php condition at footer over page template
- Retrieve tags data in post body
- Add caption functionality to custom WordPress theme
- Get_template_part inside a folder
- Best practices regarding the creation of custom widgets?
- WordPress menu link doesn’t work properly
- Search filter by Post title OR Meta Title Value [duplicate]
- admin-ajax.php + load-scripts.php hanging for minutes
- Unique sequential reservation code
- How to use get_template part in the plugin?
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- different style sheet for just one page template
- Replace single_template filter with what for default posts?
- Control the srcset much more (not all sizes in it each time)
- I have problems with loading javascripts
- Pass variable from action back to template
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Best way to handle lack of titles in microblogging
- Functions php shortcode for displaying main menu with no child items
- How to include any template using Shortcode fuction?
- WP Customizer API loaded into functions.php
- call_user_func_array() expects parameter 1 to be a valid callback, function
- Using functions.php to include code that’s processed inline
- why can’t i add front.css to my frontpage.php
- Page Template Won’t Load Correct CSS File
- contact form in template with jquery,validate and ajax
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Show admin page, only if function is being used
- Function to check if custom page is used by page?
- Simplest Way to Build Custom Archives Page?
- Unable to use get_page_by_title() more than once per page?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Advanced method to control cache of enqueued style/script
- How to require a config file in a template and in function.php?
- Load templates, pass arguments, and render output from functions.php
- Probleme shortcode with list author
- Enqueue script if not page template
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- How to customize archive widget only for cpt?
- Add meta data in head from theme
- what is `get_section()` and how to use it?
- WP Enqueue Script Error
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- WordPress function with attribute pass to template
- Edit meta fields from within template
- Javascript and Stylesheet in child page
- Create a variable with string, array or multiple values
- How to pass a variable from a template page to the child theme functions.php
- Query custom post type and showing its content
- How to use different jquery function of idangero swiper dependant on page template?
- Allow tags and attributes in post and pages content
- Adding css tweak based on page template
- Why functions metaboxes is causing White Screen in Admin [closed]
- Loop on a wordpress Page instead of content coming from the WP text editor
- Getting error on function.php
- My website is generating weired url parameters of paginated pages
- What is the point of using the front-page.php template? [closed]
- Logout redirect via page template without confirmation?
- How to store page-{id}.php templates in custom folder