【发布时间】:2020-06-22 22:02:12
【问题描述】:
我有一个 Wordpress 网站,我使用“帖子”菜单创建产品页面,因为该网站用作目录,没有在线购买。我现在正试图在同一个安装中建立一个博客。是否可以复制“帖子”菜单选项和页面功能来为“博客”创建新的管理菜单。我的目标是让博客和产品分开运行,这样您在博客部分就无法访问产品帖子。
【问题讨论】:
标签: wordpress product blogs posts
我有一个 Wordpress 网站,我使用“帖子”菜单创建产品页面,因为该网站用作目录,没有在线购买。我现在正试图在同一个安装中建立一个博客。是否可以复制“帖子”菜单选项和页面功能来为“博客”创建新的管理菜单。我的目标是让博客和产品分开运行,这样您在博客部分就无法访问产品帖子。
【问题讨论】:
标签: wordpress product blogs posts
【讨论】:
感谢@Dipak Dholakiya。该插件效果很好,尽管我决定不使用插件。我找到了从“wpEASYtuts”发布的解决方案。我设置了一个新的自定义帖子类型并将其用于产品。这是在我的functions.php文件中
function product_post() {
$labels = array(
'name' => _x( 'Products', 'post type general name' ),
'singular_name' => _x( 'Product', 'post type singular name' ),
'add_new' => _x( 'Add New', 'product' ),
'add_new_item' => __( 'Add New Product' ),
'edit_item' => __( 'Edit Product' ),
'new_item' => __( 'New Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
'search_items' => __( 'Search Products' ),
'not_found' => __( 'No product found' ),
'not_found_in_trash' => __( 'No product found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Products',
);
$args = array(
'labels' => $labels,
'description' => 'Holds product and product specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'has_archive' => true,
'taxonomies' => array( 'category', 'post_tag' ),
);
register_post_type( 'products', $args );
}
add_action( 'init', 'product_post' );
然后继续使用'single.php'文件重命名为'single-products.php'。
希望这对处于相同情况的任何人有所帮助。
【讨论】: