2012-07-24 173 views
3

我创建了一个自定义后类型 - 新闻 - 使用的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

请帮帮忙!

+1

您刷新了固定链接设置吗? – fuxia 2012-07-24 06:05:59

回答

8

刚刚访问在WP-admin的固定链接页面http://yoursite.com/wp-admin/options-permalink.php来解决这个问题。

为什么?

建立在WordPress插件的任何(类型后,分类法,等。)之后,WordPress的需要更新/创建一组新的重写规则(假设你使用漂亮的永久链接)。所有你需要做的是访问你的后端永久链接页面,这样你可以生成新的规则为您的新的职位类型,等等。技术术语是冲洗重写规则(http://codex.wordpress.org/Function_Reference/flush_rewrite_rules)

相关问题