ap_question_tags_html( array $args = array() )
Description #
Output tags html.
Parameters #
- $argsarray (Optional) Arguments. Default value: array()
Source #
File: includes/taxo.php
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | 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