2013-02-27 25 views
0

我正在尋找在我的自定義後類型的分類動態輸出我的類別的描述的方式,但我在我的頭上在PHP中如何實現它。我讀過the codex on category_description徹底,但沒有任何運氣。我也看過粉碎mag的this guide。 真的希望一些PHP嚮導可以拉直我出去動力輸出在WordPress的

它應該是這個樣子的多個前端顯示自定義分類類別

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

但它看起來像這樣

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

我在做什麼是這個

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

我宣佈$主持人變量這樣

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

而$主持人變量是基於我的自定義post_type,其聲明如下

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', 
      ),)); 

而且我的定製分類法是這樣聲明的

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 
      ), 
     ) 
    ); 

}; 

回答

0

以防萬一,如果這有助於。

你真的不需要那麼多的細節去。只需回顯函數category_description(),就會顯示自定義分類術語的描述。只要確保你已經添加了您的自定義分類術語描述在yourwpurl.com/wp-admin/edit-tags.php?taxonomy=custom-taxonomy-slug