Title: Trouble returning HTML code in a function
Last modified: August 22, 2016

---

# Trouble returning HTML code in a function

 *  [jsimpsonECAN](https://wordpress.org/support/users/jsimpsonecan/)
 * (@jsimpsonecan)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/trouble-returning-html-code-in-a-function/)
 * I am trying to get a return on this function in functions.php:
 * > function story_cat_slider () {
   >  ob_start();
   > $contenth = “”;
   > $contenth .= ‘<div id=”storyslider”>
    - ‘;
 * query_posts(‘cat=2’);
    while (have_posts()) : the_post();
 * $contenth .=’
    -  <a href=”‘;
    - $contenth .='”>’;
       $contenth .= the_post_thumbnail(); $contenth .= the_permalink();
      $contenth .= ‘ ‘;
    - endwhile;
    - $contenth .= ‘
       </div>’;
    - return $contenth;
    - ob_end_flush();
       }
    - but it is not working. Does anyone see anything wrong with this?

The topic ‘Trouble returning HTML code in a function’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [content](https://wordpress.org/support/topic-tag/content/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [html](https://wordpress.org/support/topic-tag/html/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jsimpsonECAN](https://wordpress.org/support/users/jsimpsonecan/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/trouble-returning-html-code-in-a-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
