我试图自定义我的WordPress,我添加了一些自定义元框(它添加了自定义字段)以在其中添加值,但我不知道如何进行此操作。。。
我想要一个元框,这将是一个下拉菜单。此元框的值将决定在帖子中使用哪个侧栏。图片如下:
我试图自定义我的WordPress,我添加了一些自定义元框(它添加了自定义字段)以在其中添加值,但我不知道如何进行此操作。。。
我想要一个元框,这将是一个下拉菜单。此元框的值将决定在帖子中使用哪个侧栏。图片如下:
安装metabox plugin 和活动:
/**** Add this code in your function.php ****/
$meta_boxes[] = array(
\'id\' => \'post_sidebar\',
\'title\' => \'post Sidebar\',
\'pages\' => array(\'post\'),
\'priority\' => \'low\',
\'fields\' => array(
array(
\'name\' => \'Post Sidebar\',
\'id\' => \'post_sidebar\',
\'type\' => \'select\',
"options" => array( "0" => "OFF", "1" => "Left side", "2" => "Right Side"),
),
)
);
if ( class_exists( \'RW_Meta_Box\' ) )
{
foreach ( $meta_boxes as $meta_box )
{
new RW_Meta_Box( $meta_box );
}
}
/**** after single.php on get value using this one option ****/
$sidebar_value = get_post_meta($post->ID,\'post_sidebar\',true);
if($sidebar_value == 1 && $sidebar_value!=0){
// Add sidebar code for left side
}
if($sidebar_value==\'2\' && $sidebar_value!=0){
// Add sidebar code for right side
}
我想为自定义帖子类型类别检索一个包含特定用户帖子的数组。然而,get\\u posts($arg)返回此自定义post类型的所有post,尽管我指定了post\\u作者<?php $pages = get_posts(array(\'post_type\' => \'profile\',\'post_author\' => $post->post_author)); ?> <?php var_dump ($pages); ?> 在本例