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.
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:
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.