Replies: 0
Hello everyone,
I’m trying to create a function that allows me to replace the tag description with the excerpt of the same name/slug.
i.e. mypage.com/category/apples and mypage/tags/apple
Is this possible?
Here is what I have so far:
function tags(){
if (is_page('tag')){$tags = get_tags();}
else{$tags = get_the_tags();}
if (! $tags){echo "";}
else{
$html = '<ul class="tags">' . "\r\n\t" . '<li>Tags: </li>' . "\r\n\t" . '';
foreach ( $tags as $tag ){
$tag_link = get_tag_link( $tag->term_id );
$tag_group_labels = get_option( 'tag_group_labels', array() );
$tag_group_ids = get_option( 'tag_group_ids', array() );
$i = array_search($tag->term_group, $tag_group_ids);
$lower = array_map('strtolower', $tag_group_labels);
$description = str_replace('"', "''", $tag->description);
global $post;
$post_id = $tag->slug;
$id = get_post($post_id);
$html .= '<li class="' . $lower[$i] . ' ' . $tag->slug . ' tag">' . "\n\t";
$html .= '<a href="' . $tag_link . '"';
$html .= ' title="' . $tag->name . "\n\n";
$html .= 'tag name: ' . $post_id . "\n\n";
$html .= 'post name: ' . $post->post_name . "\n\n";
$html .= 'post id:' . get_the_ID() . "\n\n";
$html .= 'tag description: ' . $description . "\n\n";
$html .= 'Tagged in ' . $tag->count . ' posts' . "\n\n";
$html .= 'Catergory: ' . $tag_group_labels[$i] . "\n" . '">';
$html .= $tag->name;
$html .= '</a></li> '. "\n\n\t";
}
$html .= '</ul>';
echo $html;
echo "\r\n";
}
}
$description is pulling in the actual description of the tag not the excerpt of the corresponding post.
Thanx for looking,
Sam
- This topic was modified 23 minutes ago by Galaxy_High. Reason: Formatting
- This topic was modified 20 minutes ago by Galaxy_High.