Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Display tags for posts under Work Category?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #44216
    JokerMartini
    Participant

    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?

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

    TAG NAME GOES HERE

    #111423
    TheDoc
    Member

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

    #132436
    JokerMartini
    Participant

    @TheDoc

    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!

    #132444
    contentJones
    Member

    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.

    ID,’specialties’);
    if(!empty($all_terms)){
    if(!is_wp_error( $all_terms )) {
    foreach($all_terms as $term) {
    echo $term->name.’, ‘;
    }
    }
    }
    ?>

    #132445
    TheDoc
    Member

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.