Title: Need help to solve a code problem
Last modified: August 30, 2016

---

# Need help to solve a code problem

 *  Resolved [roger riesbeck](https://wordpress.org/support/users/roger-riesbeck/)
 * (@roger-riesbeck)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/)
 * it is this line that started the … $output .= ‘<a href
    sublime text shows the
   error and when I inspect the web browser, it is precisely this line is wrong?
   but I can not see the error! <?php $categories = get_the_category( ); $separator
   = “, “; $output = ”; if ($categories){ foreach ($categories as $category ) { 
   $output .= ‘term_id) . ‘”>’ . $category->cat_name . ‘‘ . $separator; } echo trim(
   $output, $separator); }
 * ?>

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

 *  [michal.lausch](https://wordpress.org/support/users/michallausch/)
 * (@michallausch)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769804)
 * Hi,
 * Can You please paste that code again putting it in backticks?
    Right now it’s
   a little bit messy here.
 * Greetings
    M
 *  Thread Starter [roger riesbeck](https://wordpress.org/support/users/roger-riesbeck/)
 * (@roger-riesbeck)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769806)
 *  Thread Starter [roger riesbeck](https://wordpress.org/support/users/roger-riesbeck/)
 * (@roger-riesbeck)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769808)
 * Sorry it my first time to post and I don´t get it right…here is a link to the
   code.
    [http://stackoverflow.com/questions/33826588/wordpress-php-and-html](http://stackoverflow.com/questions/33826588/wordpress-php-and-html)
 *  [michal.lausch](https://wordpress.org/support/users/michallausch/)
 * (@michallausch)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769822)
 * Hi,
 * Well, the piece of code in question is:
 *     ```
       <?php
               $categories = get_the_category( );
               $separator = ", ";
               $output = '';
   
               if ($categories){
                   foreach ($categories as $category ) {
                    $output .= '<a href="' . get_the_category_link($category->term_id) . '">' . $category->cat_name . '</a>' . $separator;
                   }
                   echo trim($output, $separator);
               }
       ?>
       ```
   
 * Have You tried to use :
    `get_category_link($category->term_id)` instead of: `
   get_the_category_link($category->term_id)` ?
 * Greetings
    M
 *  Thread Starter [roger riesbeck](https://wordpress.org/support/users/roger-riesbeck/)
 * (@roger-riesbeck)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769830)
 * Finally …. big thanks for your help !!! what is the difference between . get_category_link
   and. get_the_category_link?
 *  [michal.lausch](https://wordpress.org/support/users/michallausch/)
 * (@michallausch)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769836)
 * Well…
 * Main difference is that get_category_link exists and get_the_category_link do
   not.
 * I do that same mistake at least once a month:)
 * Greetings
    M

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

The topic ‘Need help to solve a code problem’ is closed to new replies.

## Tags

 * [CODE problem](https://wordpress.org/support/topic-tag/code-problem/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [michal.lausch](https://wordpress.org/support/users/michallausch/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/need-help-to-solve-a-code-problem/#post-6769836)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
