Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 更改模板时在写文章/页面中显示元框_Wordpress_Templates_Meta Boxes - Fatal编程技术网

Wordpress 更改模板时在写文章/页面中显示元框

Wordpress 更改模板时在写文章/页面中显示元框,wordpress,templates,meta-boxes,Wordpress,Templates,Meta Boxes,我可以很好地创建元盒,如果我将元盒分配给特定模板,它们在添加新页面屏幕中会很好地显示,但只有在保存新页面后才会显示 是否有一种方法可以在模板值更改时显示/隐藏metabox…而不必先保存页面?添加到WP管理页面 jQuery(document).ready(function($) { $("#page_template").live('change',function(){ var getCurrentTemplate = $("#page_template").val();

我可以很好地创建元盒,如果我将元盒分配给特定模板,它们在添加新页面屏幕中会很好地显示,但只有在保存新页面后才会显示


是否有一种方法可以在模板值更改时显示/隐藏metabox…而不必先保存页面?

添加到WP管理页面

jQuery(document).ready(function($) {

$("#page_template").live('change',function(){

    var getCurrentTemplate = $("#page_template").val(); 

    if( getCurrentTemplate == "template-contact.php"){

            $("#pageheading-hide").attr('checked', true);
            $("#pageheading").css({'display':'block'});
    }
    else{
        $("#pageheading-hide").attr('checked', false);
        $("#pageheading").css({'display':'none'});
    }

});

});