• Resolved webmasteral

    (@webmasteral)


    In ACT-displayer.php
    line 252

            if ($author_posts) {
                echo '<ul>';
                $i = 0;
                foreach ($author_posts as $author_post) {
                    /* excluded categories   */
                    if (has_category(explode(',', $atts['exclude']), $author_post->ID)) :
                        continue;
                    endif;
                    $postdate = date_i18n( get_option( 'date_format' ), strtotime($author_post->post_date)).' - ';  
                    echo '<li>';
                    echo ($atts['postdate'] ? $postdate : ''). '<a href="' . get_permalink( $author_post->ID ) . '">'.$author_post->post_title.'</a>';
                    $categories = get_the_category( $author_post->ID );
                    $list_cats =null;
                    foreach ($categories as $cat) :
                        $list_cats .= $cat->name.", ";
                    endforeach;
                    $list_cats = substr($list_cats, 0, -2);
                    echo "<p>" .the_tags(). "</p>";
                    echo '</li>';
                    $i++;
                    if ($atts['postsperauthor'] > -1) :
                        if ($i >= $atts['postsperauthor']) :
                            break;
                        endif;
                    endif;
                }
            }

    at the echo "<p>" .the_tags(). "</p>"; I am trying to get the posts tags to display but cant seem to pull and display the tag data correctly.

    Any ideas on how to display the posts tags after the post title?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author fmarzocca

    (@fmarzocca)

    the_tags() should be used inside the Loop. Try this instead:

    get_the_tags($author_post)

    This returns an array of tags. Then you have to cross the array if you want to echo it out.

    • This reply was modified 1 year, 10 months ago by fmarzocca.
    • This reply was modified 1 year, 10 months ago by fmarzocca.

    That got an output, the word “Array”

    echo "<p>" .get_the_tags($author_post). "</p>";

    So thats progress 🙂

    Plugin Author fmarzocca

    (@fmarzocca)

    Of course, I told you. It is an array and you need to traverse it.
    I can’t teach you php.

    Thank you for your hint, I was able to traverse the array and get the tags to display but now I think im just missing something about formatting the output because there is an extra (comma) at the end of the list

    $tags = get_the_tags($author_post);
                    echo '<div class="righttext">- Tags: ';
                    foreach ( (array) $tags as $tag ) {
                        echo $tag->name. ', ';
                    }
                    echo '</div>';

    Thanks again for your help.

    Plugin Author fmarzocca

    (@fmarzocca)

    Try this:

    $tags = get_the_tags($author_post);
    $tagnames = array();
        foreach ( (array) $tags as $tag ) {
            array_push($tagnames, $tag->name);
        }
    $comma_separated = implode(",", $tagnames);
    echo '<div class="righttext">- Tags: '.$comma_separated.'</div>';

    Thank you, that looks great.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Feture Request’ is closed to new replies.