WordPress的自定义帖子类型+(YARPP)
问题描述:
我期待添加(YARPP)到我的自定义帖子类型页面。WordPress的自定义帖子类型+(YARPP)
我期待添加的自定义帖子类型非常复杂,我正在寻找从YARPP提供的代码的位置。
这是我发现配股代码为自定义后类型的支持:
这是我的代码:
function property_listing() {
$args = array(
'description' => 'Property Post Type',
'show_ui' => true,
'menu_position' => 4,
'exclude_from_search' => true,
'labels' => array(
'name'=> 'Property Listings',
'singular_name' => 'Property Listings',
'add_new' => 'Add New Property',
'add_new_item' => 'Add New Property',
'edit' => 'Edit Properties',
'edit_item' => 'Edit Property',
'new-item' => 'New Property',
'view' => 'View Property',
'view_item' => 'View Property',
'search_items' => 'Search Properties',
'not_found' => 'No Properties Found',
'not_found_in_trash' => 'No Properties Found in Trash',
'parent' => 'Parent Property'
),
'public' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'query_var' => true,
'supports' => array('title', 'editor', 'thumbnail', 'author', 'comments')
);
register_post_type('property' , $args);
flush_rewrite_rules();
}
任何想法?
答
是的。在这里很容易看数组的末尾:
我说:'yarpp_support' => true
function property_listing() {
$args = array(
'description' => 'Property Post Type',
'show_ui' => true,
'menu_position' => 4,
'exclude_from_search' => true,
'labels' => array(
'name'=> 'Property Listings',
'singular_name' => 'Property Listings',
'add_new' => 'Add New Property',
'add_new_item' => 'Add New Property',
'edit' => 'Edit Properties',
'edit_item' => 'Edit Property',
'new-item' => 'New Property',
'view' => 'View Property',
'view_item' => 'View Property',
'search_items' => 'Search Properties',
'not_found' => 'No Properties Found',
'not_found_in_trash' => 'No Properties Found in Trash',
'parent' => 'Parent Property'
),
'public' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'query_var' => true,
'supports' => array('title', 'editor', 'thumbnail', 'author', 'comments'),
'yarpp_support' => true
);
register_post_type('property' , $args);
flush_rewrite_rules();
}
答
尝试添加以下代码到你的主题的functions.php文件:
function wpurp_register_post_type($args)
{
$args['yarpp_support'] = true;
return $args;
}
add_filter('wpurp_register_post_type', 'wpurp_register_post_type');
您还添加这在一个儿童主题中,所以你不必担心更新主题。