2

My question is fairly basic. I have an archive.php and inside I have the main loop like so:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Do stuff here

<?php endwhile; endif; ?>

Works fine for categories but not for custom taxonomies. I have a custom taxonomy called "Type". I go to the WordPress menu and add the term "Spa Break" from the "Type" taxonomy.

This works, however I get about 10 of each post for every post. All the ID's for the duplicate posts are the same, it just decides to list 10 of each.

I have added no custom queries or anything like that.

Any clues to what might be happening?

Here is my taxonomy:

function build_taxonomies(){
register_taxonomy("type", array("venue"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => array('slug' => 'type'))); 

}

Here is my post type code:

function create_post_type() 
{
    $labels = array(
        'name' => __( 'Venue' ),
        'singular_name' => __( 'Venue' ),
        'rewrite' => array('slug' => 'venues'),
        'add_new' => _x('Add New', 'venue'),
        'add_new_item' => __('Add New Venue'),
        'edit_item' => __('Edit Venue'),
        'new_item' => __('New Venue'),
        'view_item' => __('View Venue'),
        'search_items' => __('Search Venue'),
        'not_found' =>  __('No venues found'),
        'not_found_in_trash' => __('No venues found in Trash'), 
        'parent_item_colon' => ''
      );

      $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail', 'custom-fields', 'comments')
      ); 

      register_post_type('venue',$args);
}

Thanks in advance.

1
  • @user2005: Can you list the plugins you use on your site? Do you still have the problem if you disable all plugins? If you don't do anything with the query, probably some other plugin does.
    – Jan Fabry
    Commented Dec 28, 2010 at 16:46

1 Answer 1

1

The code you posted looks generally okay to me but as far as I know the rewrite parameter must be of type array or string, not bool:

register_taxonomy(
  'type', 
  array('venue'), 
  array(
    'label' => 'Types',
    'singular_label' => 'Type', 
    'rewrite' => array('slug' => 'type', 'hierarchical' => true),
    'hierarchical' => true, 
  )
);

Probably this is of help. The example code on Custom Taxonomies (Wordpress Codex) did work for me. As I do not have any idea about the venue object type you're using I was not able to check your code directly.

1
  • Thanks for the reply, however this did not fix my issue. I have updated my question with the post_type code.
    – user2005
    Commented Dec 18, 2010 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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