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've been writing up some code which enables two post types to share a custom taxonomy. From the admin side, it works fantastically - but for some reason, when I look at the taxonomy archive itself on the site,

/country/{country} , despite the fact that there are two posts (one from each type) in the taxonomy, it comes back with 'No posts found' but not a 404 error. I wonder if I've missed something to make it work - my code is below.

register_taxonomy(
        'country',
        array('hotels', 'attractions'),
        array(
            'label' => __( 'Country' ),
            'hierarchical' => true,
            'sort' => true,
            'args' => array( 'orderby' => 'term_order' ),
            'rewrite' => array( 'slug' => 'country' )
        )
    );
share|improve this question
    
Did you update the permalink structure after making the changes? You might need to visit the permalinks settings page and update (no changes need to be made, visiting it might be enough but I'd click the update button to be sure). –  Jeremy Jared May 30 '12 at 8:52
    
I did - and that made the other sections (the individual posts) work great - but hasn't done anything for the archive pages for some reason. –  George Pearce May 30 '12 at 9:07
    
@iampearce post your custom types creation scripts. –  Eugene Manuilov Jun 4 '12 at 18:46
    
Are both post types custom posttypes or is one a 'post'? –  janw Jun 4 '12 at 19:10
    
as @iampearce says, please post more code. Post the full function you're using to register the taxonomy and post types. –  mrwweb Jun 5 '12 at 18:02

3 Answers 3

up vote 0 down vote accepted
+50

As the page is returning with "no posts found", it's possible that whatever template page is generating term archives isn't including your custom post types in its query.

If you take a look at the template that should be easy to see.

share|improve this answer

Not sure what do you mean by "two post types to share a custom taxonomy". As I understand correct you can try to add to functions.php something like this:

function customposttype_rewrites($wp_rewrite) {
    $newrules = array();
    $newrules['country/([^/]+)/?$'] = 'index.php?name=$matches[1]&taxonomy=country&term=$matches[1]';

    $wp_rewrite->rules = $newrules + $wp_rewrite->rules;
}
add_filter('generate_rewrite_rules', 'customposttype_rewrites');
share|improve this answer

Your will need to edit the taxonomy page. By default it will only get 'post' not custom post types.

Adjust the query which has run on the page with the right posttypes. http://codex.wordpress.org/Class_Reference/WP_Query#Type_.26_Status_Parameters

share|improve this answer

Your Answer

 
discard

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.