我有一个名为“摇滚”的自定义帖子和分类法“流派”,我需要用标签或类似的东西来过滤帖子
post\\u type>taxonomy>taxonomy\\u标记(tagsss)
我找不到解决方案:(
我已经在功能中注册了一个新的标签分类法(比如标签)(这不是一个好的选择)
add_action( \'init\', \'create_tag_taxonomiess\', 0 );
function create_tag_taxonomiess()
{
// Add new taxonomy, NOT hierarchical (like tags)
$labels = array(
\'name\' => _x( \'Tags\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Tag\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Tags\' ),
\'popular_items\' => __( \'Popular Tags\' ),
\'all_items\' => __( \'All Tags\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit Tag\' ),
\'update_item\' => __( \'Update Tag\' ),
\'add_new_item\' => __( \'Add New Tag\' ),
\'new_item_name\' => __( \'New Tag Name\' ),
\'separate_items_with_commas\' => __( \'Separate tags with commas\' ),
\'add_or_remove_items\' => __( \'Add or remove tags\' ),
\'choose_from_most_used\' => __( \'Choose from the most used tags\' ),
\'menu_name\' => __( \'Tags\' ),
);
register_taxonomy(\'tagsss\',\'rock\',array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'tag\' ),
));
}
分类法中的我的循环类型事件。php
<?php $args = array( \'post_type\' => \'rock\',\'taxonomy\' => \'genres\',\'tagsss\' =>\'concerts\', \'orderby\' => \'menu-order\' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $rock; ?>
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile;?>
EDIT:
我自己找到了解决办法
<?php
$args = array(
\'tax_query\' => array(
array(
\'posts_per_page\' => 5,
\'order\' => \'DESC\',
\'taxonomy\' => \'tagsss\',
\'field\' => \'slug\',
\'terms\' => \'concerts\',
)
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();?>