Opened 10 years ago
Closed 10 years ago
#31394 closed defect (bug) (duplicate)
"Page not found" on preview of custom post type with post format
Reported by: | juanfra | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | administration | Cc: |
Description
If you click "Preview Changes" for a custom post type item (with post format), you get 404.
Here is the code to test on any theme's functions.php
if ( ! function_exists( 'my_custom_cpt' ) ) :
add_action( 'init', 'my_custom_cpt' );
/**
* Add a 'test' custom post type, with a post format.
*
* @since eva'
*/
function my_custom_cpt() {
$labels = array(
'name' => __( 'Test', 'textdomain' ),
'singular_name' => __( 'Test', 'textdomain' ),
'add_new' => __( 'Add New', 'textdomain' ),
'add_new_item' => __( 'Add New Test', 'textdomain' ),
'edit_item' => __( 'Edit Test', 'textdomain' ),
'new_item' => __( 'New Test', 'textdomain' ),
'view_item' => __( 'View Test', 'textdomain' ),
'search_items' => __( 'Search Test', 'textdomain' ),
'not_found' => __( 'No Tests found', 'textdomain' ),
'not_found_in_trash' => __( 'No Tests found in Trash', 'textdomain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'test' ),
'capability_type' => 'page',
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'comments', 'author', 'revisions' )
);
// register the test post type.
register_post_type( 'test', $args );
// add post a format
add_theme_support(
'post-formats',
array( 'video' )
);
add_post_type_support( 'test', 'post-formats' );
} // end my_custom_cpt()
endif;
If you remove the post_format url parameter by hand, you get to see the preview, but not updated. If you do it programatically then you get to see the preview updated.
function remove_post_format_parameter( $url ) {
$url = remove_query_arg( 'post_format', $url );
return $url;
}
add_filter( 'preview_post_link', 'remove_post_format_parameter', 9999 );
Change History (3)
Note: See
TracTickets for help on using
tickets.
#31555 was marked as a duplicate.