ap_question_tags_html( array $args = array() )
Description #
Output tags html.
Parameters #
- $argsarray (Optional) Arguments. Default value: array()
Source #
File: includes/taxo.php
function ap_question_tags_html( $args = array() ) {
$defaults = array(
'question_id' => get_the_ID(),
'list' => false,
'tag' => 'span',
'class' => 'question-tags',
'label' => __( 'Tagged', 'anspress-question-answer' ),
'echo' => false,
'show' => 0,
);
if ( ! is_array( $args ) ) {
$defaults['question_id '] = $args;
$args = $defaults;
} else {
$args = wp_parse_args( $args, $defaults );
}
$tags = get_the_terms( $args['question_id'], 'question_tag' );
if ( $tags && count( $tags ) > 0 ) {
$o = '';
if ( $args['list'] ) {
$o .= '<ul class="' . $args['class'] . '" itemprop="keywords">';
foreach ( $tags as $t ) {
$o .= '<li><a href="' . esc_url( get_term_link( $t ) ) . '" title="' . $t->description . '">' . $t->name . ' × <i class="tax-count">' . $t->count . '</i></a></li>';
}
$o .= '</ul>';
} else {
$o .= $args['label'];
$o .= '<' . $args['tag'] . ' class="' . $args['class'] . '" itemprop="keywords">';
$i = 1;
foreach ( $tags as $t ) {
$o .= '<a href="' . esc_url( get_term_link( $t ) ) . '" title="' . $t->description . '">' . $t->name . '</a> ';
++$i;
}
$o .= '</' . $args['tag'] . '>';
}
if ( $args['echo'] ) {
echo $o; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
return $o;
}
}
Expand full source code Collapse full source code View on GitHub: includes/taxo.php:342
Add your comment