如何在添加新页面内的顺序属性中添加下一个高度数字。

时间:2015-03-25 作者:Pavnish Yadav

enter image description here

默认情况下,添加新页面时,将为其指定尚未分配给页面的下一个最大数字。

1 个回复
SO网友:Pavnish Yadav

add_action( \'admin_footer\', \'my_action_javascript\' ); // Write our JS below here
function my_action_javascript()
    global $wpdb;
    $pageposts = $wpdb->get_var("SELECT max(menu_order) FROM $wpdb->posts WHERE post_status = \'publish\' AND post_type =\'post_trainers\'");
    ?>

<script type="text/javascript" >
    jQuery(document).ready(function($) {

        var data = {
            \'action\': \'my_action\',
            \'whatever\': <?=$pageposts?>
        };

        $.post(ajaxurl, data, function(response) {
               if($(\'#menu_order\').val()==\'\' || $(\'#menu_order\').val()==\'0\')
                $(\'#menu_order\').val(response);
        });
    });
</script> <?php
}

add_action( \'wp_ajax_my_action\', \'my_action_callback\' );
function my_action_callback() {
global $wpdb; // this is how you get access to the database

$whatever = intval( $_POST[\'whatever\'] );

$whatever += 1;
echo $whatever;
wp_die(); // this is required to terminate immediately and return a proper response
}
我昨天正在解决这个问题

结束

相关推荐

更改wp-admin/Customize.php中的设置会将CSS样式恢复为父主题

我有一个构建在樱桃框架主题之上的儿童主题。每当管理员用户转到wp admin/customize时。php并更改滑块,CSS将被完全破坏,需要备份。有没有人对Cherry框架有过任何经验,以及为什么它会导致这种情况?What would I need to add (or remove) to the functions.php to completely disable the customize page to prevent the end user from accidentally causin