Title: Creating a Shortcode to invoke another shortcode
Last modified: August 31, 2016

---

# Creating a Shortcode to invoke another shortcode

 *  Resolved [jeff9315](https://wordpress.org/support/users/jeff9315/)
 * (@jeff9315)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/creating-a-shortcode-to-invoke-another-shortcode/)
 * I’m trying to use Code Snippets to create a shortcode that invokes another shortcode.
   However, all it does is display the inner-shortcode instead of executing it. 
   Is this possible using Code Snippets? Here is my code:
 *     ```
       add_shortcode('list_docs', 'HOA_list_docs');
       function HOA_list_docs( $atts, $content = null ) {
       	$a = shortcode_atts( array(
       		'category' => '',
       		'item_width' => '45',
       		'style' => 'sc-list'
       	), $atts );
       	$category   = $a['category'];
       	$item_width = $a['item_width'];
       	$style      = $a['style'];
   
         $my_shortcode = "";
         $basic_mla_value = <<<EOV
       mla_gallery mla_style="$style" columns=1 attachment_category="$category" post_mime_type=application/pdf link=file mla_item_width="$item_width"
       EOV
       ;
       $my_shortcode = "[" . $basic_mla_value . "]";
       return $my_shortcode;
       }
       ```
   
 * And here is the output:
 *     ```
       [mla_gallery mla_style="sc-list" columns=1 attachment_category="abcd efgh" post_mime_type=application/pdf link=file mla_item_width="45"]
       ```
   
 * Thanks … Jeff
 * [https://wordpress.org/plugins/code-snippets/](https://wordpress.org/plugins/code-snippets/)

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

 *  Thread Starter [jeff9315](https://wordpress.org/support/users/jeff9315/)
 * (@jeff9315)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/creating-a-shortcode-to-invoke-another-shortcode/#post-7220153)
 * The solution was really obvious in hindsite. My return statement should have 
   been:
 *     ```
       return do_shortcode($my_shortcode);
       ```
   
 *  Thread Starter [jeff9315](https://wordpress.org/support/users/jeff9315/)
 * (@jeff9315)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/creating-a-shortcode-to-invoke-another-shortcode/#post-7220166)
 * I forgot to mark this resolved.

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

The topic ‘Creating a Shortcode to invoke another shortcode’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [jeff9315](https://wordpress.org/support/users/jeff9315/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/creating-a-shortcode-to-invoke-another-shortcode/#post-7220166)
 * Status: resolved