Title: A little code help
Last modified: August 19, 2016

---

# A little code help

 *  [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/a-little-code-help/)
 * 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 />";
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/a-little-code-help/#post-1268340)
 * `get_the_tags` needs the post ID..
 * Trimmed version… 😉
 *     ```
       echo count( get_the_tags( $post->ID ) );
       ```
   
 *  Thread Starter [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/a-little-code-help/#post-1268384)
 * Thanks, t31os_, I’ll look into that 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘A little code help’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [richarduk](https://wordpress.org/support/users/richarduk/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/a-little-code-help/#post-1268384)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
