Give help. Get help.

  • # April 18, 2013 at 9:09 am

    How 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?

    < ?php
    $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;
    $result = count($all_tags);
    if ( $result >= 1) { ?>
    < ?php
    $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

    < ?php } else { ?>
    No Tags!
    < ?php } ?>< ?php
    ?>< ?php wp_reset_query(); ?>

    Then lastly place each tag inside the mark up of:


    # April 18, 2013 at 12:33 pm

    There 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


    Let 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

    Stripping 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.

    < ?php $all_terms = wp_get_object_terms($post->ID,’specialties’);
    if(!is_wp_error( $all_terms )) {
    foreach($all_terms as $term) {
    echo $term->name.’, ‘;

    # April 19, 2013 at 11:18 am

    Looks 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:

    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 . ‘‘;

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.