Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm in a pickle and unfortunately, have almost zero working understanding of mod_rewrite/apache stuff. Here's what's going on:

I've got a hierarchal custom post type with parents and children. On my test server, before I can see any of the custom posts, i needed to go to the permalinks settings page and hit refresh. Then I can see parents. When I hit it again, I can see children, and I'm golden.

On the actual server (my friend's shared hosting account) -- I follow the same process and the parent's come through -- but not the children. I know it's not a plugin issue, because it's true with them all turned off, and also on the test server with them all turned on.

The child posts DO come through when i have the settings at default permalinks -- so I know the posts are actually getting created. I'm thinking it has to be something on the shared server -- any ideas what to look for? It's so weird that parent's work but children don't...

Thanks!

martin

--Since it's working on the test server, I'm pretty sure my code is right -- but just in case, this is how i'm registering them:

register_post_type('book', array(
    'label' => __('Books'),
    'singular_label' => __('Book'),
    'public' => true,
    'show_ui' => true,
    '_builtin' => false, // It's a custom post type, not built in!
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'hierarchical' => true,
    'rewrite' => array("slug" => "book"), // Permalinks format
    'query_var' => false,
    'supports' => array('title', 'editor', 'comments','thumbnail','page-attributes')
));


add_action( 'init', 'create_book_taxonomies', 0 );
function create_book_taxonomies() {
    register_taxonomy( 'format', 'book', array( 'hierarchical' => true, 'label' => 
        __('Formats', 'series'), 'query_var' => 'format' ) );

}

-cheers, mc.

share|improve this question
2  
@Martin - Can you update your question to add some example URLs that you want to use? I'm not 100% clear on what you are trying to accomplish. –  MikeSchinkel Dec 18 '10 at 9:34
    
Could only post one link -- The Working example (absent of most content) martinconnelly.com/catbox/book/parent-book –  Martin Dec 18 '10 at 14:45
1  
I Got it! query_var needs to be TRUE. Easy Peasy. Phew. –  Martin Dec 20 '10 at 19:46
    
You should post that as an answer and set it as correct. That way, we don't have an "unanswered" question, and you get some reputation to boot! –  John P Bloch Dec 21 '10 at 17:12
    
Thanks John, It's so rare i'm actually in a position to answer a question, even if it's my own... –  Martin Dec 22 '10 at 4:03
add comment

1 Answer

up vote 1 down vote accepted

So it turns out the difference between the working site and the broken site was actually in the code (thank god). 'query_var' needs to be set to => "true". There's still a little funkiness, where posts with the same name (but different parents and thus different permalinks) seem like they auto direct to the earliest instance -- but that's fixable by adding a prefix in the permalink edit section of the write screen. For ease of others, here's how I'm registering the post type:

register_post_type('book', array(
    'label' => __('Books'),
    'singular_label' => __('Book'),
    'public' => true,
    'show_ui' => true,
    '_builtin' => false, // It's a custom post type, not built in!
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'hierarchical' => true,
    'rewrite' => array("slug" => "book"), // Permalinks format
    'query_var' => false,
    'supports' => array('title', 'editor', 'comments','thumbnail','page-attributes')
));


add_action( 'init', 'create_book_taxonomies', 0 );
function create_book_taxonomies() {
    register_taxonomy( 'format', 'book', array( 'hierarchical' => true, 'label' => 
        __('Formats', 'series'), 'query_var' => 'format' ) );

}

Cheers,

M

share|improve this answer
add comment

Your Answer

 
discard

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