<div id="filtering-nav">
<a href="#" class="filter-btn"><span>Filter</span></a>
<ul>
<li><a href="#all" class="all">All</a></li>
<?php $args=array(\'orderby\' => \'name\',\'taxonomy\'=>\'galleries\');
$galleries=get_categories($args);
foreach($galleries as $gallery){ ?>
<li><a href="<?php echo get_category_link( $gallery->term_id ) ; ?>" class="<?php echo $gallery->gallery_nicename; ?>"><?php echo $gallery->name; ?></a></li>
<?php } ?>
</ul>
<div class="clearfix"></div>
当您将参数传递给get\\u categories函数时,需要将分类名称作为分类参数传递,以检索分类,而不是类别。。。
这是完整的参考资料。。
http://codex.wordpress.org/Function_Reference/get_categories
将您的代码与下面的代码进行比较,您在register post type的args中缺少分类法,而在custom taxonomy arg中重写slug。下面的代码工作正常。
$custom_slug = get_option(\'slug\') != \'\' ? get_option(\'slug\') : \'portfolio\';
$args = array(
\'labels\' => array(
\'name\' => __(\'Portfolio\'),
\'singular_name\' => __(\'Portfolio Project\'),
\'add_new\' => __(\'Add Project\'),
\'add_new_item\' => __(\'Add Project\'),
\'new_item\' => __(\'Add Project\'),
\'view_item\' => __(\'View Project\'),
\'search_items\' => __(\'Search Portfolio\'),
\'edit_item\' => __(\'Edit Project\'),
\'all_items\' => __(\'Complete Portfolio\'),
\'not_found\' => __(\'No Projects found\'),
\'not_found_in_trash\' => __(\'No Projects found in Trash\')
),
\'taxonomies\' => array(\'portfolio-categories\', \'portfolio-clients\', \'portfolio-tags\'),
\'public\' => true,
\'show_ui\' => true,
\'_builtin\' => false,
\'_edit_link\' => \'post.php?post=%d\',
\'capability_type\' => \'post\',
\'rewrite\' => array(\'slug\' => __($custom_slug)),
\'hierarchical\' => false,
\'menu_position\' => 20,
\'menu_icon\' => WP_PLUGIN_URL . \'/portfolio/images/icon.jpg\',
\'supports\' => array(\'title\', \'editor\')
);
/** create portfolio categories (taxonomy) */
register_taxonomy(\'portfolio-categories\', \'project\', array(
\'hierarchical\' => true,
\'show_ui\' => true,
\'rewrite\' => array(\'slug\' => __($custom_slug . \'/category\')),
\'labels\' => array(
\'name\' => __(\'Portfolio Categories\'),
\'singular_name\' => __(\'Portfolio Category\'),
\'search_items\' => __(\'Search Portfolio Categories\'),
\'popular_items\' => __(\'Popular Portfolio Categories\'),
\'all_items\' => __(\'All Portfolio Categories\' ),
\'parent_item\' => __(\'Parent Portfolio Category\'),
\'parent_item_colon\' => __(\'Parent Portfolio Category\'),
\'edit_item\' => __(\'Edit Portfolio Category\'),
\'update_item\' => __(\'Update Portfolio Category\'),
\'add_new_item\' => __(\'Add New Portfolio Category\'),
\'new_item_name\' => __(\'New Portfolio Category\'),
\'separate_items_with_commas\' => __(\'Separate Portfolio Categories with commas\'),
\'add_or_remove_items\' => __(\'Add or remove Portfolio Categories\'),
\'choose_from_most_used\' => __(\'Choose from the most used Portfolio Categories\')
)
));
/** create new custom post type */
register_post_type(\'portfolio\', $args);