Skip to content

Instantly share code, notes, and snippets.

@wbxpress
Created May 27, 2021 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbxpress/2460f551dac34f6d13929d39ec6401ff to your computer and use it in GitHub Desktop.
Save wbxpress/2460f551dac34f6d13929d39ec6401ff to your computer and use it in GitHub Desktop.
function departmentlist() {
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
) );
echo '<br />';
foreach( $categories as $category ) {
$category_link = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( get_category_link( $category->term_id ) ),
esc_html( $category->name )
);
echo '<tab>' . sprintf( esc_html__( '%s', 'textdomain' ), $category_link ) . '</tab> ';
}
}
add_shortcode('departments', 'departmentlist');
function subjectlist() {
$tags = get_tags( array(
'orderby' => 'name',
'order' => 'ASC'
) );
echo '<br />';
foreach( $tags as $tag ) {
$tag_link = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( get_tag_link( $tag->term_id ) ),
esc_html( $tag->name )
);
echo '<tab>' . sprintf( esc_html__( '%s', 'textdomain' ), $tag_link ) . '</tab> ';
}
}
add_shortcode('subjects', 'subjectlist');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment