Question

I've setup a custom post type and a custom taxonomy for that post type, but I'm having one problem - on the custom taxonomy permalink pages, the content of the custom post that should be there is not being displayed. However, looking at the page source, I can see that there is a div that should contain the post content.

Any suggestions on how to get the entire content to be displayed?

Edit: The Custom Post Types UI plugin was used for the creation of the custom post types and the custom taxonomies.

Edit 2: Turns out it was a Thesis problem. Design Options > Display Options > Archives was set to "titles only", which kept the content of the posts from being displayed.

Was it helpful?

Solution

By default, a custom post type isn't included in the standard query. You'll need to manually create a query in your taxonomy page for that post type.

OTHER TIPS

Give this a shot, adding into your functions file

add_filter( 'pre_get_posts', 'include_tax_posts' );

function include_tax_posts( $query ) {

    if ( is_tax()  && false == $query->query_vars['suppress_filters'] )
        $query->set( 'post_type', array( 'post', 'page', 'YOUR_POST_TYPE' ) );

    return $query;
}

Ok, did a bit of digging and it appears as though there is a ticket to fix this in the 3.1 release. Until then, you might wanna try using this plugin: http://wordpress.org/extend/plugins/simple-custom-post-type-archives/

The other option, since it's Thesis, is use their custom loop API and create a query to run on all pages being set from that taxonomy / post type.

I don't know if this will help you where it looks like you are using a plugin to create custom post types and taxonomies (never had much like with those). This is what my developer did to get posts from a custom taxonomy to show up on a custom post page when the slugs match. Similar to what you're doing but technically in reverse...

In Functions.php...

Create custom post type to custom taxonomy relation

    global $post_tax;
    $post_tax = array(
        'store' => array('post' => 'stores', 'tax' => 'store'),
        'state' => array('post' => 'states', 'tax' => 'state')
    );

Register post types

function post_types_custom_init() {

global $post_tax;

register_post_type($post_tax['store']['post'], array('label' => 'Stores','public' => true,'show_ui' => true,'_builtin' => false, 'capability_type' => 'post','hierarchical' => true,'rewrite' => array('slug' => 'stores'),'query_var' => true,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes')) );

register_post_type($post_tax['state']['post'], array('label' => 'States','public' => true,'show_ui' => true,'_builtin' => false, 'capability_type' => 'post','hierarchical' => true,'rewrite' => array('slug' => 'states'),'query_var' => true,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes')) );

}

Hook into the init action and call create_post_type_taxonomies when it fires

add_action( 'init', 'create_beer_taxonomies', 0 );

Create taxonomies for their corresponding post types

function create_beer_taxonomies() 
{

global $post_tax;

// Add new taxonomy
  $labels = array(
    'name' => _x( 'Stores', 'taxonomy general name' ),
    'singular_name' => _x( 'Store', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Stores' ),
    'all_items' => __( 'All Stores' ),
    'parent_item' => __( 'Parent Store' ),
    'parent_item_colon' => __( 'Parent Store:' ),
    'edit_item' => __( 'Edit Store' ), 
    'update_item' => __( 'Update Store' ),
    'add_new_item' => __( 'Add New Store' ),
    'new_item_name' => __( 'New Store Name' ),
  );    

// Make it hierarchical (like categories) and assign to specific post types
  register_taxonomy($post_tax['store']['tax'],
    array('post',$post_tax['review']['post']),
    array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'stores-bp' ),
  ));

  $labels = array(
    'name' => _x( 'States', 'taxonomy general name' ),
    'singular_name' => _x( 'State', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search States' ),
    'all_items' => __( 'All States' ),
    'parent_item' => __( 'Parent State' ),
    'parent_item_colon' => __( 'Parent State:' ),
    'edit_item' => __( 'Edit State' ), 
    'update_item' => __( 'Update State' ),
    'add_new_item' => __( 'Add New State' ),
    'new_item_name' => __( 'New State Name' ),
  );

  register_taxonomy($post_tax['state']['tax'],
        array('post',$post_tax['beer']['review']),
    array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'states-bp' ),
  ));

}

In Template/Loop

function meta_loop_beers($queried_tax,$queried_term){
    //$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    $queried_page = get_query_var('paged');
    $paged = $queried_page ? $queried_page : 1;

    $post_type = '';

    global $post_tax;
    foreach($post_tax as $relation){
        if( $relation['tax'] == $queried_tax ){
            $post_type = $relation['post'];
            break;
        }

    }


        $args=array(
          'post_type' => 'post',
          $queried_tax => $queried_term,
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
        );

        $my_query = null;
        $my_query = new WP_Query($args);

<PUT LOOP(S) HERE>

        wp_reset_query();


}

I believe* that is everything. You won't be able to copy-paste that code and get it working for you automatically but it will hopefully give you an idea as to how to get it to work. This was bleeding edge stuff at the time, completed about 6 months ago and I'm guessing there is a better implementation somewhere. Unfortunately, the site is still not live so nothing to show at the moment.

We also had to redirect (htaccess) those slugs for the taxonomies as we wanted those looking for the store (post type) and archive for the stores (taxonomy) to land on the same page where the 'profile page' of the store displayed both.

So the end result is that the archive page for domain.com/stores-bp/walmart will redirect to domain.com/stores/walmart.

Way too confusing! I can try to clarify where needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top