Title: Adding shortcode to a slider`s text
Last modified: August 21, 2016

---

# Adding shortcode to a slider`s text

 *  Resolved [blueberry25](https://wordpress.org/support/users/blueberry25/)
 * (@blueberry25)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/)
 * Hello,
    I’m trying to add a shortcode that allows html entities (unordered list)
   in the slider’s text. I’ve past this code to the functions.php (found thanks 
   to customizr forum):
 *     ```
       add_filter('tc_slide_text_length', 'my_tc_slide_text_length');
       function my_tc_slide_text_length(){
           return 500; /*change this value to suit your needs*/
       }
       add_filter('tc_slider_display', 'do_my_shortcode');
       function do_my_shortcode($html){
           return do_shortcode(html_entity_decode($html));
       }
       ```
   
 * Then I was trying to figure out how to add the shortcode to the slider’s text
   without any success for now.
    Thanks a lot for help.

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

 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938897)
 * Hi [@blueberry](https://wordpress.org/support/users/blueberry/)
    You can’t put
   html code in the slide description text. Using the code above you need additional
   code to achieve that. It’s quite an hack, but… whatever works, isn’t it? 🙂 Our
   goal is to put something like html code in a shortcode and render it, right? 
   So try adding this to your child-theme functions.php:
 *     ```
       add_shortcode('htmlify', 'do_html');
       function do_html($attr, $content){
           return str_replace(array('{','}'), array('<','>'), $content);
       }
       ```
   
 * Then in the slide’s description box put something like this:
 *     ```
       [htmlify]{/p}{ul class="my_class"}{li}first{/li}{li}second{/li}{/ul}{p}[/htmlify]
       ```
   
 * Those leading `{/p}` and trailing `{p}`, are there ’cause by default customizr
   wraps the slide’s description text in `<p class="lead">` `</p>`. So to keep our
   html valid we close that `<p clas="lead">` with `</p>` and open a new `<p>` before
   the end to match the dangling `</p>`. Is this understandable? (sorry for my english).
   You may want to have some text before and after the ul, then what you have to
   use in the description box is something like this:
    `[htmlify]SOMETHING BEFORE{/
   p}{ul class="my_class"}{li}first{/li}{li}second{/li}{/ul}{p class="lead"}SOMETHING
   AFTER[/htmlify]`.
 * Hope this helps
 *  Thread Starter [blueberry25](https://wordpress.org/support/users/blueberry25/)
 * (@blueberry25)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938903)
 * Hi d4z_c0nf,
    Thanks a lot for your help and the explanation! I literary copy/
   pasted your codes but it didn`t work… The slider is showing the text with the
   code.
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938906)
 * That’s what I have in my child-theme functions.php
 *     ```
       add_filter('tc_slide_text_length', 'my_tc_slide_text_length');
       function my_tc_slide_text_length(){
           return 500; /*change this value to suit your needs*/
       }
       add_filter('tc_slider_display', 'do_my_shortcode');
       function do_my_shortcode($html){
           return do_shortcode(html_entity_decode($html));
       }
       add_shortcode('htmlify', 'do_html');
       function do_html($attr, $content){
           return str_replace(array('{','}'), array('<','>'), $content);
       }
       ```
   
 * That’s what I have in the **slide** description box (not the image caption/description
   box):
 *     ```
       [htmlify]{/p}{ul class="my_class"}{li}first{/li}{li}second{/li}{/ul}{p}[/htmlify]
       ```
   
 * Is it the same you have?
 * That’s the result -> [http://i58.tinypic.com/akihx4.png](http://i58.tinypic.com/akihx4.png)
 * Can you be more specific about “The slider is showing the text with the code.”
   you mean the whole shortcode `[htmlify]....[/htmlify]` or just `{/p}{ul class
   ="my_class"}{li}first{/li}{li}second{/li}{/ul}{p}`
    ?
 *  Thread Starter [blueberry25](https://wordpress.org/support/users/blueberry25/)
 * (@blueberry25)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938907)
 * It works!!!
 * I`m sorry, I removed the second filter code while copy-pasting. That`s why it
   didn`t work.
 * Many thanks!
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938908)
 * Perfect! You’re welcome 😀
    Could you mark this topic as resolved? Thank you.
 *  Thread Starter [blueberry25](https://wordpress.org/support/users/blueberry25/)
 * (@blueberry25)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938909)
 * Done:)
 *  [ElectricFeet](https://wordpress.org/support/users/electricfeet/)
 * (@electricfeet)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938968)
 * Neat! 🙂 Glad to have you back!
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [12 years ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4938977)
 * Hehe, I have to make a snippet for this, and add instruction for use for it and
   that one for featured pages.
    Thanks ElectricFeet 🙂
 *  [jolieaparis](https://wordpress.org/support/users/jolieaparis/)
 * (@jolieaparis)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4939098)
 * Hi there,
 * I don’t know if I’m doing something really stupid, but when I try this, all of
   the code appears on the slider. So rather than just seeing the text, you can 
   also see the [htmlify]{p} etc.
 * I’ve copied and pasted the code (both filters and the shortcode) to my functions.
   php and have added the [htmlify] {p} and {br /} tags to my slider’s caption, 
   so I’m not sure what I’m doing wrong 🙁
 * Any suggestions?
 *  [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * (@d4z_c0nf)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4939099)
 * Hi jolieaparis,
    works fine here. Did you copy this whole code [https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text?replies=10#post-5607868](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text?replies=10#post-5607868)
 * in your child-theme functions.php?
 * Can I see the content of this file?
    Please copy the content in pastebin.com 
   and then put the link here.

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

The topic ‘Adding shortcode to a slider`s text’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/customizr/4.4.24/screenshot.png)
 * Customizr
 * [Support Threads](https://wordpress.org/support/theme/customizr/)
 * [Active Topics](https://wordpress.org/support/theme/customizr/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/customizr/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/customizr/reviews/)

## Tags

 * [HTML entities](https://wordpress.org/support/topic-tag/html-entities/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 10 replies
 * 4 participants
 * Last reply from: [Rocco Aliberti](https://wordpress.org/support/users/d4z_c0nf/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/adding-shortcode-to-a-sliders-text/#post-4939099)
 * Status: resolved