Wordpress预览在自定义帖子类型上打破

时间:2013-10-23 21:13:51

标签: http-status-code-404 wordpress custom-post-type

我在自定义帖子类型中无法预览帖子。如果我在列出所有帖子的页面上并按下预览按钮,则可以正常工作。但当我进入帖子并单击“预览更改”按钮时,我会收到404错误页面。

我已更新并保存了永久链接。我将帖子类型设置为public_queryable。

如果我在浏览器中禁用了Javascript,那么预览按钮就可以工作,但这意味着我必须更改我不想做的Wordpress核心文件。

这是我的自定义帖子类型结构:

    function my_custom_post_attq() {
$labels = array(
    'name'               => _x( 'Product' ),
    'singular_name'      => _x( 'product' ),
    'add_new'            => _x( 'New product' ),
    'add_new_item'       => __( 'add product' ),
    'edit_item'          => __( 'edit product' ),
    'new_item'           => __( 'new product' ),
    'all_items'          => __( 'all products' ),
    'view_item'          => __( 'view product' ),
    'search_items'       => __( 'search products' ),
    'not_found'          => __( 'product not found' ),
    'not_found_in_trash' => __( 'product not found in trash' ), 
    'parent_item_colon'  => '',
    'menu_name'          => 'product'
);
$args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'attq' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => 8,
    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields', 'post-formats' ),
    'taxonomies'         => array( 'category', 'post_tag')
     );
register_post_type( 'attq', $args );    
    }
    add_action( 'init', 'my_custom_post_attq', 'flush_rewrite_rules' );

我的永久链接结构是

    /%year%/%monthnum%/%day%/%postname%/

有人有任何建议吗?

1 个答案:

答案 0 :(得分:7)

我采用了'后格式'走出args阵列。这解决了这个问题。 Wordpress正在寻找帖子格式,我没有在我的自定义帖子类型中创建任何格式。