Problem with shortcode inside a shortcode

Here’s a trick that wp-includes/media.php uses for the embed shortcode: first remove all shortcodes, then add a specific shortcode back to the system, filter your content for it, then re-register the original shortcodes. Try this: function etdc_tab_group( $atts, $content ){ global $shortcode_tags; $GLOBALS[‘tab_count’] = 0; // save the shortcode registrations $orig_shortcode_tags = $shortcode_tags; // remove … Read more

Hide/disable sidebar using shortcode?

Use this code to echo your div’s ID <?php $sidebar_layout = get_post_meta($post->ID, ‘sidebar-layout’, $single = true); ?> <div id=”<?php echo $sidebar_layout ?>”> <div class=”content”> … </div> <div class=”sidebar”> … </div> </div> If you want to apply styles according to the selection the user has made then change your style sheet as follows: #left .content{ … … Read more

Dynamic number within shortcode

Shortcodes are plain text wrapper made exactly for cases when PHP code is not available or should not be used. You can concatenate that to string and evaluate it with do_shortcode(). You can look up function that powers shortcode (set up with add_shortcode()) and use it in PHP code directly.

hard code shortcode only on specific category

If you’re embedding the code directly into the template file, why bother with shortcodes? Simply extract the code from the add_shortcode() function call, and add it to your template, wrapped in an appropriate conditional tag, such as in_category(), e.g.: if ( in_category( $cat ) ) { // put shortcode code here } Note: the $cat … Read more

How to add shortcode to show/hide press releases?

I coded this up quickly, based on Scribu’s writeup on script loading, might work for you or provide a starting point. The plugin file: <?php /* Plugin Name: MO_expander_shortcode */ class MO_expander_shortcode { static $add_script; function init() { add_shortcode(‘moexpander’, array(__CLASS__, ‘handle_shortcode’)); add_action(‘wp_footer’, array(__CLASS__, ‘add_script’)); } function handle_shortcode($atts, $content = null) { self::$add_script = true; // … Read more

Trouble passing attribute into shortcode function

Sorry I deleted my comment because I found the issue. You need to do an html entity decode on query variable. Use the code below. function hey_query_shortcode( $atts ) { extract( shortcode_atts( array( ‘query’ => ”, ‘style’ => ” ), $atts ) ); $query = html_entity_decode( $query ); ob_start(); $the_query = new WP_Query( $query ); … Read more

post var problem with shortcode loop

you really shouldn’t use query_posts() for anything other then the main query of the page. Instead you should use wp_query() or get_posts() , also since you return a value before running wp_reset_query() then its never actually being reset. so change your shortcode to this: function casestudy_shortcode($atts){ extract(shortcode_atts(array( ‘type’ => ‘case_studies’, ‘limit’ => ‘1’, ‘case’ => … Read more