Make WordPress Core


Ignore:
Timestamp:
09/24/2014 09:29:15 PM (10 years ago)
Author:
SergeyBiryukov
Message:

Create correct permalinks for child posts of hierarchical post types when default permalinks are used.

props loushou.
fixes #29615 for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/results.php

    r28809 r29765  
    652652    }
    653653
     654    /**
     655     * @ticket 29615
     656     */
     657    function test_child_post_in_hierarchical_post_type_with_default_permalinks() {
     658        global $wp_rewrite;
     659
     660        $old_permastruct = get_option( 'permalink_structure' );
     661        $wp_rewrite->set_permalink_structure( '' );
     662        $wp_rewrite->flush_rules();
     663
     664        register_post_type( 'handbook', array( 'hierarchical' => true ) );
     665
     666        $post_1 = $this->factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
     667        $post_2 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) );
     668
     669        $this->assertContains( 'contributing-to-the-wordpress-codex/getting-started', get_permalink( $post_2 ) );
     670
     671        $result = $this->q->query( array( 'handbook' => 'contributing-to-the-wordpress-codex/getting-started', 'post_type' => 'handbook' ) );
     672        $this->assertCount( 1, $result );
     673
     674        $wp_rewrite->set_permalink_structure( $old_permastruct );
     675        $wp_rewrite->flush_rules();
     676    }
     677
    654678}
Note: See TracChangeset for help on using the changeset viewer.