php facetwp将标签添加到类别facet
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php facetwp将标签添加到类别facet相关的知识,希望对你有一定的参考价值。
<?php
add_filter( 'facetwp_indexer_row_data', function( $rows, $params ) {
if ( 'cases_topics' == $params['facet']['name'] ) {
$post_id = $params['defaults']['post_id'];
$tags = get_tags( $post_id );
if ( !empty( $tags ) ) {
foreach ( $tags as $tag ) {
$new_row = $params['defaults'];
$new_row['facet_source'] = 'tax/post_tag';
$new_row['facet_value'] = $tag->slug;
$new_row['facet_display_value'] = $tag->name;
$new_row['term_id'] = $tag->term_id;
$rows[] = $new_row;
}
}
}
return $rows;
}, 10, 2 );
以上是关于php facetwp将标签添加到类别facet的主要内容,如果未能解决你的问题,请参考以下文章
php facetwp将span添加到复选框标签
php facetwp将facet术语选项与分类法归档页面的层次结构相匹配
php facetwp facetwp_facet_filter_posts钩子
php facetwp用facet的map facet替换listify map
php facetwp修改facet计数
php facetwp在autoselect上重置facet