gpt4 book ai didi

wordpress - 为什么我的自定义帖子类型帖子不显示?

转载 作者:行者123 更新时间:2023-12-03 08:12:14 25 4
gpt4 key购买 nike

我创建了一个自定义帖子类型 - Press - 在functions.php中使用以下代码:

// Press Custom Post Type //

function press_custom_init() {

$labels = array(
'name' => _x('Press', 'post type general name'),
'singular_name' => _x('Press', 'post type singular name'),
'add_new' => _x('Add New', 'press'),
'add_new_item' => __('Add New Press Item'),
'edit_item' => __('Edit Item'),
'new_item' => __('New Press Item'),
'view_item' => __('View Press Item'),
'search_items' => __('Search Press'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => false,
'query_var' => true,
'rewrite' => array('slug','pages'),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 5,
'supports' => array('title','editor','thumbnail','excerpt',)
);

register_post_type( 'press' , $args );
}
add_action( 'init', 'press_custom_init' );

我已经添加了该帖子类型的项目并在我的导航栏中添加了一个菜单项,但是当我点击链接时,我收到一条“未找到帖子”的消息。

您可以在这里查看:http://s13.mynewsitereview.com//press

请帮忙!

最佳答案

只需访问 WP-admin 中的永久链接页面 http://yoursite.com/wp-admin/options-permalink.php 即可解决此问题。

为什么?

在 WordPress 中创建任何插件(帖子类型、分类法等)后,WordPress 需要更新/创建一组新的重写规则(假设您使用的是漂亮的永久链接)。您需要做的就是访问后端的永久链接页面,以便为您的新帖子类型等生成新规则。技术术语是刷新重写规则 (http://codex.wordpress.org/Function_Reference/flush_rewrite_rules)

关于wordpress - 为什么我的自定义帖子类型帖子不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11622819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com