Forums

A little code help (3 posts)

  1. richarduk
    Member
    Posted 2 years ago #

    This is within the loop.

    I'm trying to create an array by getting the number of tags from each post and counting them, then outputting the result (just to check that everything works)

    What am I doing wrong?

    $counttags=array();
    $posttags=array();
    
    $posttags = get_the_tags();
    $counttags[]= count($posttags);

    Then, outside the loop

    foreach( $counttags as $key => $value){
    	echo "$key, $value <br />";
  2. Mark / t31os
    Moderator
    Posted 2 years ago #

    get_the_tags needs the post ID..

    Trimmed version... ;)

    echo count( get_the_tags( $post->ID ) );
  3. richarduk
    Member
    Posted 2 years ago #

    Thanks, t31os_, I'll look into that :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags