admin管理员组文章数量:1279147
Im using wordpress custom post types for "resources"
The custom post type is called "resource"
Then I created 3 different "post templates" for the post type
webinars, news, gated content
Using different POST TEMPLATES for that.
everything works great there is just one thing I can't accomplish
need to disable/remove " Default Template" from the menu
and set "webinar" as the default one..
Im using wordpress custom post types for "resources"
The custom post type is called "resource"
Then I created 3 different "post templates" for the post type
webinars, news, gated content
Using different POST TEMPLATES for that.
everything works great there is just one thing I can't accomplish
need to disable/remove " Default Template" from the menu
and set "webinar" as the default one..
Share Improve this question edited Oct 4, 2021 at 9:50 Tom J Nowell♦ 61k7 gold badges79 silver badges148 bronze badges asked Oct 4, 2021 at 9:05 gil hamergil hamer 6713 gold badges21 silver badges37 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 1If you want to change only the text you can hook into default_page_template_title
add_filter('default_page_template_title', 'bt_change_default_page_template_title', 10, 2);
function bt_change_default_page_template_title ($text, $meta) {
if ($meta === 'meta-box') return 'My custom template';
return $text;
}
Add this code into functions.php
and thats it.
Tested on a clean wordpress install, this will only change the text and nothing else, functionality will remain the same.
Update
To get this filter to work with ACF we need to make a few changes.
- ACF doesn't pass a second argument when using the filter so we need to assing a default value to our second parameter
- Update our condition to take that new, empty, parameter into account
add_filter('default_page_template_title', 'bt_change_default_page_template_title', 10, 2);
function bt_change_default_page_template_title ($text, $meta = '') {
if ($meta === 'meta-box' || empty($meta)) return 'My custom templatee';
return $text;
}
本文标签: wordpress posts template remove default template from menu
版权声明:本文标题:wordpress posts template remove default template from menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741286566a2370304.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
single-resource.php
file, couldn't you put the webinar template in there? – Tom J Nowell ♦ Commented Oct 4, 2021 at 9:48