这里有一个干净的方法来完成你所需要的。
注册自定义帖子类型(sans post\\u标记和类别)
注册特定于书签的分类法为书签选项创建帖子元框(包括示例)。您可以在元框中添加nofollow复选框选项保存post metaadd_action(\'init\', \'bookmark_post_type\');
function bookmark_post_type()
{
$labels = array(
\'name\' => _x(\'Bookmark\', \'post type general name\'),
\'singular_name\' => _x(\'Bookmark\', \'post type singular name\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Add New Bookmark\'),
\'edit_item\' => __(\'Edit Bookmark\'),
\'new_item\' => __(\'New Bookmark\'),
\'all_items\' => __(\'All Bookmarks\'),
\'view_item\' => __(\'View Bookmark\'),
\'search_items\' => __(\'Search Bookmarks\'),\'not_found\' => __(\'No website Bookmarks found\'),
\'not_found_in_trash\' => __(\'No Bookmarks found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Bookmarks\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'bookmark\',
\'with_front\' => false),
//\'taxonomies\' => array(\'post_tag\', \'category\'),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'can_export\' => true,
\'supports\' => array(
\'post-thumbnails\',
\'thumbnail\',
\'editor\',
\'title\'
)
);
register_post_type(\'bookmarks\', $args);
$labels = array(
\'name\' => _x( \'Bookmark Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Categories\' ),
\'all_items\' => __( \'All Categories\' ),
\'parent_item\' => __( \'Parent Category\' ),
\'parent_item_colon\' => __( \'Parent Category:\' ),
\'edit_item\' => __( \'Edit Category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New Genre Category\' ),
\'menu_name\' => __( \'Bookmark Categories\' ),
);
register_taxonomy(\'bookmark_categories\',array(\'bookmarks\'), array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'bookmarks_categories\' ),
));
$labels = array(
\'name\' => _x( \'Bookmark Tags\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Tag\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Tags\' ),
\'popular_items\' => __( \'Popular Tags\' ),
\'all_items\' => __( \'All Tags\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit Tag\' ),
\'update_item\' => __( \'Update Tag\' ),
\'add_new_item\' => __( \'Add New Tag\' ),
\'new_item_name\' => __( \'New Tag Name\' ),
\'separate_items_with_commas\' => __( \'Separate tags with commas\' ),
\'add_or_remove_items\' => __( \'Add or remove tags\' ),
\'choose_from_most_used\' => __( \'Choose from the most used tags\' ),
\'menu_name\' => __( \'Bookmark Tags\' ),
);
register_taxonomy(\'bookmark_tags\',\'bookmarks\',array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'bookmark_tags\' ),
));
}
//Create meta box
add_action(\'admin_init\', \'bookmark_meta_boxes\');
function bookmark_meta_boxes(){
add_meta_box(\'bookmarks-meta\', __(\'Bookmark Options\'), \'bookmark_options\', \'bookmarks\', \'normal\', \'high\');
}
//Meta box form data
function bookmark_options(){
global $post;
$url = get_post_meta($post->ID, \'bookmark-url\', true);
echo "
<div>
<label for=\'bookmark-url\'>URL</label>
<input style=\'width:100%; padding:4px;\' type=\'text\' name=\'bookmark-url\' value=\'$url\' />
</div>
";
}
//Save the form data
add_action(\'save_post\', \'bookmark_save\');
function bookmark_save($post_ID){
//Do nonce checking here
if(\'bookmarks\' === $_REQUEST[\'post_type\']){
update_post_meta($post_ID, \'bookmark-url\', esc_html($_REQUEST[\'bookmark-url\']));
}
}
要从主循环中删除书签,请在循环代码上方添加以下内容:
query_posts(\'post_type=post\');
如果要控制CPT的存档和单个上下文,则需要添加两个名为存档书签的文件。php和单个书签。php
通过在帖子类型中保持“public\\u queryable”为true,可以搜索书签帖子。
您可以对屏幕截图图像使用\\u post\\u缩略图功能。
我会使用内容/编辑器区域来描述您的书签。