Hi,
how can I sort tags in TagPages?
Thanks a lot
Benna
Hi,
how can I sort tags in TagPages?
Thanks a lot
Benna
Hi Benna84,
TagPages extends the default WordPress functionality, thus all built-in WordPress functions can be used to sort your tags in the front- and backend. In other words you can implement the same template tags which you use to sort your post-tags.
Have a look at the TagPages Faq for a few links.
Greetz,
Berny
Hi Berny,
thank you for the fast answer, but, I admit, I'm not an expert WP coder, so I can't solve this problem.
I've used this plugin in this way:
<?php
//inserisco gli sport adatti per il prodotto in questione
$tags = get_page_tags($post->ID);
if (count($tags)) { ?>
<h5><span>Sport</span></h5>
<ul class="sport-list">
<?
foreach($tags as $tag) {
echo '<li class="tag-'.$tag->slug.'"><a href="'.get_bloginfo('wpurl').'/sport/'.$tag->slug.'"><img src="'.get_bloginfo('stylesheet_directory').'/timthumb.php?src=wp-content/uploads/sport/'.$tag->slug.'.png&h=100&w=85&zc=1" alt="'.$tag->name.'" /></a></li>';
}
?>
</ul>
<? } ?>
but I don't know how tags are ordered by.
It will be amazing if I can add a score to order this list, like pages, but also in alphabetical mode...
Thanks a lot,
Benna
Sorry, Benna, I don't understand your question. - What do you mean by 'add a score to order this list, like pages, but also in alphabetical mode'?
Can you give me an example?
Hi Berny,
I'm sorry, probably my reply wasn't very clear.
You know, you can order pages with Order in Paga Attributes. So the number that you place in Order was my 'score' in the previous post.
This was the best way to solve my problem, but I can be happy also with an alphabetical order for my tags, like this
01 Basketball
02 Cycling
03 MTB
04 Running
Thanks a lot,
B
Hi Benna,
Hmm, I'm still not a 100% sure, but I've tried to rework your example.
Querying for the tags on a page can be done with wp_get_post_tags (in wp-includes/post.php) which calls wp_get_object_terms (in wp-includes/taxonomy.php).
As you've installed TagPages (in most cases) you can use the post-functions also for pages, because TagPages extends WordPress by using the same 'Post-Tags' taxonomy for pages which you would normally only use for posts.
<?php
global $post;
//inserisco gli sport adatti per il prodotto in questione
$tags = wp_get_post_tags($post->ID, array('orderby' => 'name', 'order' => 'DESC'));
if (count($tags)) { ?>
<h5><span>Sport</span></h5>
<ul class="sport-list">
<?php
foreach($tags as $tag) {
echo '<li class="tag-'.$tag->slug.'"><a href="'.get_bloginfo('wpurl').'/sport/'.$tag->slug.'/"><img src="'.get_bloginfo('stylesheet_directory').'/timthumb.php?src=wp-content/uploads/sport/'.$tag->slug.'.png&h=100&w=85&zc=1" alt="'.$tag->name.'" /></a></li>';
} ?>
</ul>
<?php }
As you see, I've used a reversed alphabetical order to output the tags...
Hope that helps.
Greetz,
Berny
This topic has been closed to new replies.