Title: Adding tags SQL
Last modified: August 22, 2016

---

# Adding tags SQL

 *  [naaatasha](https://wordpress.org/support/users/naaatasha/)
 * (@naaatasha)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-tags-sql/)
 * Hey:) I have function:
 * <?php
    $posttags = get_the_tags(); $count=0; $sep=”; if ($posttags) { echo ‘ ‘;
   foreach($posttags as $tag) { $count++; echo $sep . ‘<div class=”single_tags”>
   <span class=”tag-links”>term_id).'”>’.$tag->name.’</span></div><div class=”single_tags”
   ><span class=”tag-links1″>term_id).'”>’.$tag->name.’</span></div><div class=”
   single_tags”><span class=”tag-links2″>term_id).'”>’.$tag->name.’</span></div>
   <div class=”single_tags”><span class=”tag-links3″>term_id).'”>’.$tag->name.’</
   span></div>’; $sep = ”; if($count>0) break; } } ?>
 * And this function shows 4 colorful blocks, but the only one tag i.e try try try
   try, but I would like to show try1 try2 try3 try4
 * Is there any option in this function to do this?
 * I hear that it can be done by SQL and select value. How? I’m the beginner in 
   wordpress and programming.
 * Thanks for help in advance !

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-tags-sql/#post-5365955)
 * The code you gave has compile errors. Please post the actual code you are using
   and be sure to enclose it in backticks.
 *  Thread Starter [naaatasha](https://wordpress.org/support/users/naaatasha/)
 * (@naaatasha)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-tags-sql/#post-5365959)
 * ‘
 * > <?php
   >  $posttags = get_the_tags(); $count=0; $sep=”; if ($posttags) { echo ‘‘;
   > foreach($posttags as $tag) { $count++; echo $sep . ‘<div class=”single_tags”
   > ><span class=”tag-links”>term_id).'”>’.$tag->name.'</span></div><div class=”
   > single_tags”><span class=”tag-links1″>term_id).'”>’.$tag->name.'</span></div
   > ><div class=”single_tags”><span class=”tag-links2″>term_id).'”>’.$tag->name.'
   > </span></div><div class=”single_tags”><span class=”tag-links3″>term_id).'”>’.
   > $tag->name.'</span></div>’; $sep = ”; if($count>0) break; } } ?>
 * ‘
 * I’m sure, this is corrent code. And there is no compile errors…
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-tags-sql/#post-5365962)
 * Sorry, but when I copy that code and paste it into a blank .php file, I get this
   compile error:
 * Parse error: syntax error, unexpected ‘”‘, expecting ‘,’ or ‘;’ in C:\tmp\t.php
   on line 8
 * It may be that the code is corrupted because it is not enclosed in backticks.
 *  [Julien Klepatch](https://wordpress.org/support/users/julien-klepatch/)
 * (@julien-klepatch)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/adding-tags-sql/#post-5365963)
 * I confirm, the above code compiles error. It can be seen from line 8 this code
   has problems. I am not
 * ‘<?php
    $posttags = get_the_tags(); $count=0; $sep=”; if ($posttags) { echo ‘‘;
   foreach($posttags as $tag) { echo $sep . ‘<div class=”single_tags”><span class
   =”tag-links”> . $tag->name.'</span></div> } ?>`
 * Not really sure what you mean for the color, and I dont understand why you need
   this code anyway.
 * You can directly use `the_tags()`
    [http://codex.wordpress.org/Function_Reference/the_tags](http://codex.wordpress.org/Function_Reference/the_tags)

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

The topic ‘Adding tags SQL’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Julien Klepatch](https://wordpress.org/support/users/julien-klepatch/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/adding-tags-sql/#post-5365963)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
