Last active
May 3, 2020 20:18
-
-
Save faisalahammad/d8e17518795788f53c1ab7919f4dbf37 to your computer and use it in GitHub Desktop.
Create a Taxonomy loop (all type of post type or taxonomy supported).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Term Shortcode **/ | |
function my_book_terms( $atts ) { | |
$args = array( 'hide_empty=0' ); | |
$terms = get_terms( $atts['term'], $args ); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { | |
$count = count( $terms ); | |
$i = 0; | |
$term_list = '<ul class="my-term-archive">'; | |
foreach ( $terms as $term ) { | |
$i ++; | |
$term_list .= '<li><a href="' . esc_url( get_term_link( $term ) ) . '" title="'.$term->name.' এর সকল বই দেখুন।">' . $term->name . ' (' . $term->count . ')' . '</a></li>'; | |
if ( $count != $i ) { | |
$term_list .= ''; | |
} else { | |
$term_list .= '</ul>'; | |
} | |
} | |
echo $term_list; | |
} | |
} | |
add_shortcode( 'my_terms', 'my_book_terms' ); | |
// Usages: [my_terms term='book_author' /] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment