Title: Using Functions with code that contains
Last modified: August 20, 2016

---

# Using Functions with code that contains

 *  Resolved [dyyyb](https://wordpress.org/support/users/dyyyb/)
 * (@dyyyb)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/using-functions-with-code-that-contains/)
 * Hello Community!
 * I’m sure it’s quite easy to do, but i am not so talented ;]
 * I have to make a function that outputs:
 *     ```
       </div>
       </div>
       <div class="column-sidebar nomargin">
       <?php do_action('shop_sidebar'); ?>
       </div>
       </div>
       </div>
       ```
   
 * But when i make a function:
 *     ```
       {
           echo '</div></div>';
       	echo '<div class="column-sidebar nomargin"><?php do_action('shop_sidebar'); ?></div>';
       	echo '</div></div>';
       }
       ```
   
 * I doesn’t work…

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 10 months ago](https://wordpress.org/support/topic/using-functions-with-code-that-contains/#post-2934851)
 * What do you mean
 * > I(t) doesn’t work
 * ?
 * Elaborate.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/using-functions-with-code-that-contains/#post-2934857)
 * the one line mixes strings and php;
 * try and rewrite it to:
 *     ```
       echo '<div class="column-sidebar nomargin">'; do_action('shop_sidebar'); echo '</div>';
       ```
   
 * btw: that is alot of closing divs in the output of that function – are you sure
   that results in valid html code?
 *  Thread Starter [dyyyb](https://wordpress.org/support/users/dyyyb/)
 * (@dyyyb)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/using-functions-with-code-that-contains/#post-2934862)
 * Yes, my theme contain a few divs 🙂 And that function is for wrapping a specific
   plugin – Jigoshop. My sidebar is in this particular place and i had to place 
   it somehow there.
 * Thank You alchymyth! It works like a charm 😉
 *  [emilybrown125](https://wordpress.org/support/users/emilybrown125/)
 * (@emilybrown125)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/using-functions-with-code-that-contains/#post-2934864)
 * Hi,
 * You can use the following code:
 * var url = “http:\\Google.com”
 * if(url.indexOf(url) !=
    -1)
 * {
 * //it means url contains Google word.
 * }
 * indexOf returns the position of the word in the string. If not found, it will
   return -1
 * Regards,
    _[[signature moderated]](http://codex.wordpress.org/Forum_Welcome#Signatures)_

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

The topic ‘Using Functions with code that contains’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [conversion](https://wordpress.org/support/topic-tag/conversion/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [emilybrown125](https://wordpress.org/support/users/emilybrown125/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/using-functions-with-code-that-contains/#post-2934864)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
