Forums

A little code help (3 posts)

  1. richarduk
    Member
    Posted 2 weeks 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. t31os_
    Member
    Posted 2 weeks ago #

    get_the_tags needs the post ID..

    Trimmed version... ;)

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

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

Reply

You must log in to post.

About this Topic

Tags