[wp-trac] [WordPress Trac] #31394: "Page not found" on preview of custom post type with post format

WordPress Trac noreply at wordpress.org
Fri Feb 20 17:57:27 UTC 2015


#31394: "Page not found" on preview of custom post type with post format
-------------------------------+-----------------------------
 Reporter:  juanfra            |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.1.1
 Severity:  normal             |   Keywords:
  Focuses:  administration     |
-------------------------------+-----------------------------
 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

 {{{
 #!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.

 {{{
 #!php

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

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31394>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list