Need to show different text depending on Custom Post Type Term
-
Hi I’m having a problem and I’m just running around in circles. Hopefully someone can help.
Here’s a link to the dev site that has all the CPTs, it’s the single posts that are the problem .
wideskyhosting.com/turnerphotography/galleriesI have a Custom Post Type called “gallery” with a taxonomy called “gallery_catagory”
In gallery_catagory I have catagories (I’m guessing this is a term, not 100% sure) “Wedding” “Commercial”… and a few more.
I need on each of these catagories/terms I need to display different text on each. I’ve tried a bunch of stuff but nothings working.
I tried making a template for one as a test
taxonomy-gallery-commercial.php, I tried Widget Logic, and I tried just an if/else based on the name but the closest I’ve gotten is displaying things on all the pages not each individual one.This is what my functions looks like:
add_action('init', 'galleries_register'); function galleries_register() { $labels = array( 'name' => _x('Turner Galleries', 'post type general name'), 'singular_name' => _x('Gallery', 'post type singular name'), 'add_new' => _x('Add New', 'gallery'), 'add_new_item' => __('Add New Gallery'), 'edit_item' => __('Edit Gallery'), 'new_item' => __('New Gallery'), 'view_item' => __('View Gallery'), 'search_items' => __('Search Gallery'), 'not_found' => __('Nothing found'), 'not_found_in_trash' => __('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'menu_icon' => null, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author','thumbnail','excerpt','comments','custom-fields','post-formats') ); register_post_type( 'gallery' , $args ); } function gallery_taxonomy() { //This registers the taxonomy, catagory like funtionality register_taxonomy( 'gallery_catagory', //what you want to name this taxonomy 'gallery', //what you called the CPT above array( 'hierarchical' => true, 'label' => 'Gallery Catagory', 'query_var' => true, 'rewrite' => array('slug' => 'gallery-catagory') ) ); } add_action( 'init', 'gallery_taxonomy' );
I had a thought and maybe this is the issue I just don’t know how to fix.
When you click through to each single post the url for example is
/gallery/sara-tommynot
gallery/weddings/sara-tommy
so maybe it’s a permalinks thing?Thanks for taking the time to read this long post ??
- The topic ‘Need to show different text depending on Custom Post Type Term’ is closed to new replies.