WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have my custom post type set up with hierarchicy set to true and the url works like: Lions News › S1 › Test Post 1 which is nice except that it should go one futher and be like Lions Minis › Lions News › S1 › Test Post 1 Lions Minis being the parent page to everything. Is there a way to to set that up?

The following is my setup in functions.php

/** Custom Post Types for Lions News */
 $labels = array(
'name'                          => 'Lions News Categories',
'singular_name'                 => 'Lions Category',
'search_items'                  => 'Search Lions Categories',
'popular_items'                 => 'Popular Lions Categories',
'all_items'                     => 'All Lions Categories',
'parent_item'                   => 'Parent Lions Category',
'edit_item'                     => 'Edit Lions Category',
'update_item'                   => 'Update Lions Category',
'add_new_item'                  => 'Add New Lions Category',
'new_item_name'                 => 'New Lions Category',
'separate_items_with_commas'    => 'Separate Lions Categories with commas',
'add_or_remove_items'           => 'Add or remove Lions Categories',
'choose_from_most_used'         => 'Choose from most used Lions Categories'

$args = array(
'label'                         => 'Lions Categories',
'labels'                        => $labels,
'public'                        => true,
'hierarchical'                  => true,
'show_ui'                       => true,
'show_in_nav_menus'             => true,
'args'                          => array( 'orderby' => 'term_order' ),
'rewrite'                       => array( 'slug' => 'lions_news/lions_articles', 'with_front' => false ),
'query_var'                     => true

register_taxonomy( 'lions_articles', 'lions_news', $args );

register_post_type( 'lions_news', 
    'labels'                => array(
        'name'              => __( 'Lions News' ),
        'singular_name'     => __( 'Lions News' )
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'supports'              => array( 'title','editor','thumbnail','comments','revisions' ),
    'rewrite'               => array( 'slug' => 'lions_news', 'with_front' => false ),
    'has_archive'           => true
/** End custom Post Types */


share|improve this question
up vote 4 down vote accepted

you should just be able to change this line

'rewrite' => array( 'slug' => 'lions_minis/lions_news', 'with_front' => false ),

Remember to always visit the Settings->Permalinks menu in wordpress after making a rewrite change for it to update the links!

share|improve this answer

Take a look at this line: 'rewrite' => array( 'slug' => 'lions_news', 'with_front' => false ),

share|improve this answer
I went for the obvious and added 'rewrite' => array( 'slug' => 'lions-minis', 'lions_news', 'with_front' => false ), but no joy? Also tired variations of true and false but I got nothing – Nsokyi Jul 15 '11 at 13:36
try 'with_front' => true – kaiser Jul 15 '11 at 13:50
Tried and it had no effect? – Nsokyi Jul 15 '11 at 14:19
Take a look at the Codex entry at the 'rewrite' part. – kaiser Jul 15 '11 at 16:06
nope, I read it seems if you change the rewrite part to: 'rewrite' => array( 'pages' => 'lions-minis', 'lions_news', 'lions_articles', 'with_front' => true ), Then it should work but it stubbornly stays the same? – Nsokyi Jul 18 '11 at 15:39

The below code works if you set hierarchical to false in register_post_type (my understanding here is you don't actually need hierarchical relationships between the news posts themselves, just that they need to be associated with the page hierarchy).

The following is lifted and modified from here: http://justintadlock.com/archives/2013/10/07/post-relationships-parent-to-child

/* Hook meta box to just the 'lions_news' post type. */
    add_action( 'add_meta_boxes_lions_news', 'my_add_meta_boxes' );

    /* Creates the meta box. */
    function my_add_meta_boxes( $post ) {

            'Parent Page',

    /* Displays the meta box. */
    function my_lions_news_parent_meta_box ( $post ) {

        $parents = get_pages(
                'post_type'   => 'page',
                'post_status' => 'publish', 
                'sort_column' => 'menu_order',
                'parent' => -1

        if ( !empty( $parents ) ) {

            echo '<select name="parent_id" class="widefat">'; // !Important! Don't change the 'parent_id' name attribute.

            foreach ( $parents as $parent ) {
                printf( '<option value="%s"%s>%s</option>', esc_attr( $parent->ID ), selected( $parent->ID, $post->post_parent, false ), esc_html( $parent->post_title ) );

            echo '</select>';

You can replace the 'parent' => -1 in get_pages with any page id to restrict the dropdown to show only children of that page.

Simplest from there would probably be to create a page template for all the pages with news articles assigned that has a custom loop through child posts of the current page.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.