WordPress.org

Ready to get started?Download WordPress

Forums

dynamically outputting category description from custom taxonomy (1 post)

  1. casperovergaard
    Member
    Posted 1 year ago #

    I'm looking for a way of dynamically outputting the description of my categories in my custom post type's taxonomy, but I'm over my head in php in how to achieve it.
    I've followed the codex on category_description as thorough as possible, and I've followed this guide on smashing mag
    I'm really hoping that there's some php wizards in here able to help me out :)

    It should look something like this

    <a href="#" title="category_description"></a>

    But it looks like this

    <a href="#" original-title></a>

    What I'm doing is this

    <?php echo '<li><a href="#" title="'.$presenter->description.'"</a></li>'; ?>

    I'm declaring the $presenter variable like this

    $presenter = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'portfolio' ) );

    And the $presenter variable is based on my custom post_type, which is declared like this

    register_post_type('portfolio', array( 'label' => 'Portfolio Items','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => '%portfolio_page%','with_front'=>true),'query_var' => true,'supports' => array('title','editor','trackbacks','revisions','thumbnail'),'labels' => array (
    				'name' => 'Portfolio Items',
    				'singular_name' => 'Portfolio Item',
    				'menu_name' => 'Portfolio Items',
    				'add_new' => 'Add Portfolio Item',
    				'add_new_item' => 'Add New Portfolio Item',
    				'edit' => 'Edit',
    				'edit_item' => 'Edit Portfolio Item',
    				'new_item' => 'New Portfolio Item',
    				'view' => 'View Portfolio Item',
    				'view_item' => 'View Portfolio Item',
    				'search_items' => 'Search Portfolio Items',
    				'not_found' => 'No Portfolio Items Found',
    				'not_found_in_trash' => 'No Portfolio Items Found in Trash',
    				'parent' => 'Parent Portfolio Item',
    			),) );

    And my custom taxonomy is declared like this

    function add_custom_taxonomies() {
    	register_taxonomy('p_category', 'portfolio', array(
    			'hierarchical' => true,
    			'labels' => array(
    				'name' => _x( 'Portfolio Category', 'taxonomy general name', 'theme_x' ),
    				'singular_name' => _x( 'Category', 'taxonomy singular name', 'theme_x' ),
    				'search_items' => __( 'Search Category', 'theme_x' ),
    				'all_items' => __( 'All Categories', 'theme_x' ),
    				'parent_item' => __( 'Parent Category', 'theme_x' ),
    				'parent_item_colon' => __( 'Parent Category:', 'theme_x' ),
    				'edit_item' => __( 'Edit Category', 'theme_x' ),
    				'update_item' => __( 'Update Category', 'theme_x' ),
    				'add_new_item' => __( 'Add New Category', 'theme_x' ),
    				'new_item_name' => __( 'New Category Name', 'theme_x' ),
    				'menu_name' => __( 'Portfolio Categories', 'theme_x' ),
    			),
    			'rewrite' => array(
    				'slug' => 'portfolio-category',
    				'with_front' => false,
    				'hierarchical' => true
    			),
    		)
    	);
    
    };

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by casperovergaard
  • This topic is not resolved
  • WordPress version: 3.5.1