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
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Creating a Shortcode to invoke another shortcode’ is closed to new replies.