This topic contains 0 replies, has 2 voices, and was last updated by xiligroup dev 14 years ago.
You must be logged in to reply to this topic.
dev.xiligroup is being renovated › Forums › xili-tidy-tags plugin › templating xili-tidy-tags
Tagged: group, loop, post_tag, semantic, tag, taxonomy, template tag, xili-tidy-tags
This topic contains 0 replies, has 2 voices, and was last updated by xiligroup dev 14 years ago.
I’d like to know if there is a way to just get an array of tags names and IDs that exist in a certain group. For example:
Group: Food
Tags in Group: Sandwich, Salad, Cake, Pie
xili_get_group_tags(‘Food’); would then return
array( array(‘Sandwich’,1), array(‘Salad’, 2), array(‘Cake’, 3), array(‘Pie’, 4))
Is this possible with the current available code, if not, could you give me an idea of what i’d have to do to create this function?
To do that you must use embedded new taxonomy functions inside plugin’s source :
get_terms_of_groups_new ( $group_id, $taxonomy, $taxonomy_child, $args )
Here I write a ‘raw’ example delivering expected array (here only print_r)
/**
* example of selection of tags of a group as used in xili-tidy-tags dashboard<br />
* only for tests<br />
*
*/
function xili_tags_from_group($group_name) {
// from $group_name to ID
$taxonomy = TAXOTIDYTAGS ;
$taxonomy_child = 'post_tag' ;
$groupterm = term_exists($group_name, $taxonomy);
$group_id = $groupterm['term_id'];
// return array of tags as object
$args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false ); // even if no post attached to a tag - see doc inside source of xili-tidy-tags
$thetags = get_terms_of_groups_new ( $group_id, $taxonomy, $taxonomy_child, $args );>
print_r($thetags);
// example of array as expected by S.Y. but here with key -
$result_array = array();
if ( $thetags ) {
foreach ( $thetags as $onetag ) {
$result_array[] = array('tag_name' => $onetag->name, 'tag_id' => $onetag->term_id);
}
print_r($result_array);
}
}
The default taxonomy (see file taxonomy.php in folder wp-includes) is very poweful but don’t include the queries to group tags under one another tag. Is is the purpose of this plugin xili-tidy-tags created since WP 2.7 ! Initially created to group tags by language, he structurally contains all functions to group tags by semantic groups AND one tag can belong to one or more groups.
Michel
dev.xiligroup.com
You must be logged in to reply to this topic.
Ce site utilise des cookies afin que nous puissions vous fournir la meilleure expérience utilisateur possible. Les informations sur les cookies sont stockées dans votre navigateur et remplissent des fonctions telles que vous reconnaître lorsque vous revenez sur notre site Web et aider notre équipe à comprendre les sections du site que vous trouvez les plus intéressantes et utiles.
Cette option doit être activée à tout moment afin que nous puissions enregistrer vos préférences pour les réglages de cookie.
Si vous désactivez ce cookie, nous ne pourrons pas enregistrer vos préférences. Cela signifie que chaque fois que vous visitez ce site, vous devrez activer ou désactiver à nouveau les cookies.