2012-03-14 76 views
0

所以我有一个自定义元框,我需要它是在发布标题后,有没有方法来设置位置顺序?如何设置wordpress元框位置

// LE 不起作用:

//create a variable and store the widget 
$widget1 = $wp_meta_boxes['dashboard']['normal']['core']['information']; 

// unset both widgets 
unset($wp_meta_boxes['dashboard']['normal']['core']['information']); 

//re insert widget in the order you want 
$wp_meta_boxes['dashboard']['normal']['core']['information'] = $widget1; 

回答

3

这是一个link有关强制仪表板小工具顶端。该理论可用于排列帖子/页面元框。

//create a variable and store the widget 
$widget1 = $wp_meta_boxes['dashboard']['normal']['core']['your widget id']; 
$widget2 = $wp_meta_boxes['dashboard']['normal']['core']['other widget id']; 

// unset both widgets 
unset($wp_meta_boxes['dashboard']['normal']['core']['your widget id']); 
unset($wp_meta_boxes['dashboard']['normal']['core']['other widget id']); 

//re insert widget in the order you want 
$wp_meta_boxes['dashboard']['normal']['core']['other widget id'] = $widget2; 
$wp_meta_boxes['dashboard']['normal']['core']['your widget id'] = $widget1; 

您还可以使用jQuery移动的箱子它们显示

$('#pageparentdiv').prependTo('#normal-sortables'); 
$('#panel_38').insertAfter('#pageparentdiv'); 
+0

'//创建一个变量和存储部件 $ WIDGET1 = $ wp_meta_boxes [ '仪表盘'] ['后正常'] [' 核心 '] [' 信息']; //取消设置这两个小部件 unset($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['information']); //按您要的顺序重新插入小部件 $ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['information'] = $ widget1;'不起作用 – Uffo 2012-03-14 21:18:32

+0

代码示例是用于仪表板小部件。这将不得不修改post/page元框,但理论仍然是相同的。将元框保存为变量,删除元框,将变量作为元框插入。 – Nick 2012-03-14 21:30:23

+0

所以在我的自定义帖子类型,我需要它是这样的:发布标题,自定义metabox,编辑器等... – Uffo 2012-03-14 21:39:15

相关问题