You could try using get_the_tags instead and then just display the first 4 tags in the returned array.
Hey esmi,
I tried something like this but only got one tag returned. Any help? My PHP sucks.
<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
foreach($posttags as $tag) {
$count++;
if (4 == $count) {
echo $tag->name . ' ';
}
}
}
?>
Thanks!
<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
$output = '';
foreach($posttags as $tag) {
$count++;
$output .= $tag->name . ' ';
if( $count >4 ) break;
}
}
echo $output;
?>
@esmi can you also limit the get_tag_link to 4?
Hey VincentvandenHeuvel did you ever figure out how to get this to return just 4 tag links? The example esmi gave just returns words, not links. Thanks.
@dbaker
read this:
http://codex.wordpress.org/Function_Reference/get_the_tags
http://codex.wordpress.org/Function_Reference/get_tag_link
<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
foreach($posttags as $tag) {
$count++;
echo '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a> ';
if( $count >4 ) break;
}
}
?>