Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress preview broken on custom post types

I can not preview a post when it is in a custom post type. If I am on the page where all the post are listed and press the preview button, that works fine. But wheni go into a post and click the "preview changes" button, I get a 404 error page.

I have updated and saved the permalinks. I set the post type to publicly_queryable.

If I disable Javascript in my browser, then the preview button works, but this would mean that I would have to change the Wordpress core file which I don't want to do.

Here is my custom post type structure:

    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' );

My permalinks structure is

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

Does anyone have any suggestions?

like image 294
rebelnorth Avatar asked Feb 14 '23 21:02

rebelnorth


1 Answers

I took the 'post-formats' out of the args array. This fixed the problem. Wordpress was looking for post formats and I didn't have any of them created in my custom post types.

like image 154
rebelnorth Avatar answered Feb 19 '23 04:02

rebelnorth