Support » Fixing WordPress » the_tags() vs get_the_tags() ??

  • Resolved squeaker2

    (@squeaker2)



    Hey guys, I cannot seem to get the_tags() to return my array where i want to display it on the page. It seems to have a mind of its own, or I don’t understand how echo statements work.. one of the two. Here is the code I am having problems with, maybe someone can enlighten me as to why it wont output the way I want it to.

    `
    //Loop Start
    if(have_posts()) :
    while(have_posts()) : the_post();
    $postid++; //Incriment to determine post classes

    //Get the needed Post INFO BEFORE ECHO
    $link = get_permalink(); //Define Permalink
    if ($lukeweddings == true){$link = $link . ‘&weddings=true’; $siteID = $link;}
    $title = get_the_title(); //Title Of Post
    $content = get_the_content();
    $posttags = the_tags();
    $category = the_category();
    $postOutput = preg_replace(‘/<img[^>]+./’,”, $content);

    if ($countLeftOrRight == 0){
    $countLeftOrRight++;
    }
    else {
    $countLeftOrRight = 0;
    }

    if($countLeftOrRight == 1){
    images(‘1’, ”, ”, ‘imageleft image’. $postid, $siteID);}
    else {images(‘1’, ”, ”, ‘imageright image’ . $postid, $siteID);}

    echo(‘<div class=”post” id=”post’ . $postid . ‘”>
    <div class=”heading heading’ . $postid . ‘”>
    ‘ . $title . ‘
    </div>
    <div class=”content content’ . $postid . ‘”>’
    . $postOutput .
    ‘</div>
    <div class=”readmore readmore’ . $postid . ‘”>Read More >></div>

    <div class=”postcategories”><span>Categorized Under: </span>’ . $category . ‘</div>
    <div class=”posttags”><span>Tags: </span>’ . $posttags . ‘</div>
    <div class=”returnpage”><< Return to Previous</div>
    <div class=”facebookShare facebookShare’ . $postid . ‘”>’
    . fbshare_manual() .
    ‘</div>
    <div class=”clearfloats”></div>
    <div class=”horizontalRule horizontalRule’. $postid . ‘”><img class=”imageline” src=”../../../../images/line.png” alt=”” width=”600px” /></div>
    </div>’);

    endwhile;
    endif; ?>

Viewing 1 replies (of 1 total)
  • Resolved by doing this… probably a better way to do it.. but w/e.

    $tagging = '';
    				if(get_the_tags()) $posttags = get_the_tags();
    				if ($posttags) {
    					foreach($posttags as $tag) {
    					$tagging = $tagging . '<a href="?tag='.$tag->slug.'">'.$tag->name .'</a>'. ', ';
    				}}
    
    				$category = '';
    				if(get_the_category()) $postcat = get_the_category();
    				if ($postcat) {
    					foreach($postcat as $cat) {
    					$category = $category . '<a href="?searchCat='.$cat->slug.'">'.$cat->name .'</a>'. ', ';
    				}}

Viewing 1 replies (of 1 total)
  • The topic ‘the_tags() vs get_the_tags() ??’ is closed to new replies.