Title: Pods shortcode inside shortcode: odd behavior
Last modified: March 19, 2024

---

# Pods shortcode inside shortcode: odd behavior

 *  Resolved [vi54](https://wordpress.org/support/users/vi54/)
 * (@vi54)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/)
 * When I use pods shortcodes in salient theme’s shortcodes, this usually works 
   wonders.
   However. Not with: [if] [/if]
 *     ```wp-block-code
       [if personal]
       	<h6>My Preferences:</h6>
       [fancy-ul icon_type="standard_dash" color="Accent-Color" alignment="left" spacing="5px" enable_animation="true" link_style="default"]
       {@personal}
       [/fancy-ul]
       [/if]
       ```
   
 * This breaks the salient shortcode fancy-ul.
   When I break it up: an if around 
   the H6, and and if around the fancy-ul’s content, that works but it creates unnecessary
   <p> and <br>’s
 *     ```wp-block-code
       <div class="nectar-fancy-ul animated-in" data-list-icon="icon-salient-thin-line" data-animation="true" data-animation-delay="0" data-color="accent-color" data-spacing="5px" data-alignment="left"> <p></p>
       <ul>
       <li aria-level="4" style="opacity: 1; left: 0px;"><i class="icon-default-style icon-salient-thin-line accent-color"></i> my item one</li>
       <li aria-level="4" style="opacity: 1; left: 0px;"><i class="icon-default-style icon-salient-thin-line accent-color"></i> my item two</li>
       </ul>
       <p> </p></div>
       ```
   
 * Hope this can be resolved?
   Thank you
    -  This topic was modified 2 years, 2 months ago by [vi54](https://wordpress.org/support/users/vi54/).

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

 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/#post-17512234)
 * Where are you using the `[if]` shortcode exactly?
 *  Thread Starter [vi54](https://wordpress.org/support/users/vi54/)
 * (@vi54)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/#post-17512248)
 * inside the pod template editor
 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/#post-17516901)
 * It looks like the way our shortcode runs it is adding that formatting to the `[
   fancy-ul]` shortcode output or something else is going on there. I don’t see 
   where this is happening on Pods’ side and I don’t have a way to reproduce this
   as that is a non wordpress.org theme.
 *  Plugin Support [pdclark](https://wordpress.org/support/users/pdclark/)
 * (@pdclark)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/#post-17544663)
 * Shortcodes and template magic tags and conditions are executed in different contexts,
   which can cause challenges with race conditions and formatting, as both are markup
   languages unaware of many variables and contexts available to programming languages.
 * The simplest workaround for complex recursion and conditionals which need to 
   pass information to shortcodes etc. is to define a shortcode for use in the template.
   For example, `[if_personal_fancy_preferences]`
 *     ```wp-block-code
       <?php
       add_shortcode(
         'if_personal_fancy_preferences',
         function( $atts, $content, $tagname ) {
           $personal = pods()->field( 'personal' ); // Auto-detecting the pod type... Might be a user or a post.
           if ( ! empty( $personal ) ) {
             return '<h6>My Preferences:</h6>' . apply_shortcodes(
               sprintf(
                 '[fancy-ul icon_type="standard_dash" color="Accent-Color" alignment="left" spacing="5px" enable_animation="true" link_style="default"]%s[/fancy-ul]',
                 $personal
               )
             );
           }
           return '';
         }
       );
       ```
   
 *  Thread Starter [vi54](https://wordpress.org/support/users/vi54/)
 * (@vi54)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/#post-17546169)
 * That is awesome! Learning everyday.
   I had to adapt it a bit to make it work, 
   but I understood the idea behind it.
 *     ```wp-block-code
       function preferences_code(){
       	$personal = pods()->field( 'personal' ); // Auto-detecting the pod type... Might be a user or a post.
        	if ( ! empty( $personal ) ) {
           	return '<h6>>My Preferences:</h6>' . apply_shortcodes(
               	sprintf(
                 		'[fancy-ul icon_type="standard_dash" color="Accent-Color" alignment="left" spacing="5px" enable_animation="true" link_style="default"]%s[/fancy-ul]',
                 	$personal
               	)
             	);
           }
       }
       add_shortcode('preferences_fancy', 'preferences_code');
       ```
   

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

The topic ‘Pods shortcode inside shortcode: odd behavior’ is closed to new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [vi54](https://wordpress.org/support/users/vi54/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/pods-shortcode-inside-shortcode-odd-behavior/#post-17546169)
 * Status: resolved