- This topic is empty.
-
AuthorPosts
-
April 18, 2013 at 9:09 am #44216
JokerMartini
ParticipantHow can I display the tags under the category work but without their links? Just as plain text?
I have the part that collects all the tags from posts under the category Work but I do not know how to strip them of their link?
$page_name = $wp_query->post->post_name;
$custom_query = new WP_Query(‘category_name=’. $page_name .’&posts_per_page=-1′);
if ($custom_query->have_posts()) :
while ($custom_query->have_posts()) : $custom_query->the_post();
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$all_tags[] = $tag->term_id;
}
}
endwhile;
endif;
$result = count($all_tags);
if ( $result >= 1) { ?>
$tags_arr = array_unique($all_tags);
$tags_str = implode(“,”, $tags_arr);
$args = array(
‘smallest’ => 13,
‘largest’ => 13,
‘unit’ => ‘px’,
‘number’ => 0,
‘format’ => ‘flat’,
‘separator’ => “n n n” ,
‘echo’ => true,
‘link’ => ”,
‘include’ => $tags_str
);
wp_tag_cloud($args);
?>
No Tags!
?>Then lastly place each tag inside the mark up of:
April 18, 2013 at 12:33 pm #111423TheDoc
MemberThere is a lot of code going on there and I’m not sure it’s all needed. Can you show me the output your trying to achieve in basic HTML? I know you gave an example at the end there, but you also have some tag cloud stuff going on in your PHP.
In your first `get_the_tags()` function you can just be pumping out each tag name by using `$tag->name`.
April 19, 2013 at 9:53 am #132436JokerMartini
ParticipantLet me know if this helps.
1. Create a unique array of tag names only found on “posts” in the category “work”
2. Display tags using this loop
if (count($all_tags)) {
foreach ($all_tags as $tag)
{
echo ‘‘ . $tag . ‘‘;
}
} else {
echo ‘No Tags!’;
}Let me know if that helps explain things.Thank you TheDoc!
April 19, 2013 at 11:14 am #132444contentJones
MemberStripping out the tag link is a pain. Here’s a snippet that creates a tab delimited list, but it’s for each post. Maybe there’s a way to use some of it for a category.
ID,’specialties’);
if(!empty($all_terms)){
if(!is_wp_error( $all_terms )) {
foreach($all_terms as $term) {
echo $term->name.’, ‘;
}
}
}
?>April 19, 2013 at 11:18 am #132445TheDoc
MemberLooks like there’s no default option to modify the output of wp_tag_cloud, though you can hook into it to try and remove the `href` attribute by doing something like this: http://wpsnipp.com/index.php/functions-php/remove-title-attribute-from-wp_tag_cloud/
If you’re using `wp_tag_cloud` for the font sizing component, there’s not much I can help you with there. If you don’t need the font-sizing (which I think is a bit tacky, to be honest) then you can skip using it altogether and just echo out each of your tags as you go.
if ($posttags) {
foreach($posttags as $tag) {
echo ‘‘ . $tag->term_id . ‘‘;
}
} -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.