tkhobbes
Member
Posted 4 years ago #
Hi all
I want to get a list of all bookmark categories (i. e. category IDs) - similar to what is possible with "get_categories" for the post categories. Also, I need the corresponding name for each category ID.
Reason is, I want to build a drop-down field to select bookmarks by category.
I tried wp_list_categories('echo=0'), but this does not seem to return an array or something... and then I tried get_bookmarks - but I couldn't figure out how the array is built.... can someone help me, I am pretty sure that I am quite near to the solution...
Try this:
<?php
$taxonomy = 'link_category';
$title = 'Link Category: ';
$args ='';
$terms = get_terms( $taxonomy, $args );
if ($terms) {
foreach($terms as $term) {
if ($term->count > 0) {
echo '<p>' . $title .' ID = '. $term->term_id . ' ' . $term->name . ' contains ' . $term->count . ' link(s). </p> ';
}
}
}
?>
tkhobbes
Member
Posted 4 years ago #
Thanks - I solved this with other means, meantime, as the drop-down is not necessary any more. I set this to solved, in order for others to serve as reference. :)
flyingkites
Member
Posted 3 years ago #
I cut this down to
<?php
$taxonomy = 'link_category';
$title = 'Link Category: ';
$args ='';
$terms = get_terms( $taxonomy, $args );
if ($terms) {
foreach($terms as $term) {
if ($term->count > 0) {
echo '<p>' . $term->name . ' </p> ';
}
}
}
?>
just to list the link categories. It is possible to make them clickable so you can go to a page showing that category's links?