Get Posts shortcode plugin and meta_query?

Besides the plugin not being updated, this will not work because the meta_query arg is evaluated as a string: array(3) { [“post_type”] => string(7) “project” [“meta_query”] => string(96) “array(array(‘key’ => ‘state’, ‘value’ => ‘Completed’),array(‘key’ => ‘year’,’value’ => ‘2006’))” [“suppress_filters”] => string(5) “false” } I suggest you make a custom page template, where you would directly … Read more

May i Use ShortCode in Template?

Have you tried using the do_shortcode() function? EDIT I’m not familiar with the TweetMeme shortcode, but here’s an example usage for putting a NextGen Gallery directly into a template file: echo do_shortcode( ‘[slideshow id=”1″ w=”603″ h=”270″]’ ); Simply replace with the appropriate shortcode (and parameters) for TweetMeme. Codex ref: do_shortcode() EDIT 2 With TweetMeme, you … Read more

shortcode causing the_content() to return blank?

Fixed my problem! I was finally able to find some info out there in the vast internet. Visit this site for info on fixing this odd issue. Over all using the remove_filter(‘the_content’,’wpautop’); did the trick. http://www.undermyhat.org/blog/2009/07/sudden-empty-blank-page-for-large-posts-with-wordpress/

Shortcode content not displaying on Home page

Is the homepage pulling in the_excerpt() ? If so you will have to add this to your functions.php add_filter(‘the_excerpt’, ‘do_shortcode’); This will work if you are putting in manual excerpt. It shouldn’t be stripping out the shortcode if you are using the_content() in your homepage template.

Display gallery on top before content

function gallery_first( $content) { $expr=”/\[gallery(.*?)\]/i”; return preg_replace_callback( $expr, create_function(‘$matches’, ‘return do_shortcode($matches[0]);’), $content); } add_filter( ‘the_content’, ‘gallery_first’, 6); // prio 6 executes this function previous to all other filter functions

How to Insert Shortcodes into Theme?

You can hardcode shortcodes into a theme using do_shortcode. http://codex.wordpress.org/Function_Reference/do_shortcode echo do_shortcode(‘[wp-like-locker] Your locked content here… [/wp-like-locker]’); You will most likely want to replace the hard-coded “Your locked content here…” with the function that pulls the content from the editor, like the_content http://codex.wordpress.org/Function_Reference/the_content It might look like // the loop $content = get_the_content(); echo do_shortcode(‘[wp-like-locker]’ … Read more

passing parameters to do action from shortcode to wp_footer

Use a class, store the value you need in the footer in a member variable. Sample code, not tested: add_shortcode( ‘tooltip’, array ( ‘WPSE_69605_Tooltip’, ‘shortcode_callback’ ) ); class WPSE_69605_Tooltip { protected static $var=””; public static function shortcode_callback( $atts, $content=”” ) { self::$var=”foo”; add_action( ‘wp_footer’, array ( __CLASS__, ‘footer’ ) ); } public static function footer() … Read more

WordPress display image link in shortcode

You can reuse the $content parameter: function image_code($atts, $content = null) { $url = esc_url( $content ); return “<a href=”https://wordpress.stackexchange.com/questions/78252/$url”><img src=”https://wordpress.stackexchange.com/questions/78252/$url” class=”user-imgs” /></a>”; } Or pass the URL as parameter in case you want to use a different URL: function image_code($atts, $content = null) { $args = shortcode_atts( array( ‘url’ => FALSE ), $atts ); … Read more

How do i display the built-in gallery inside a widget?

Widgets don’t usually allow shortcodes in them (they treat them as normal text). What you have to do, is to tell this widget, it should run do_shortcode on it’s text. To do it, you can use this snippet: add_filter(‘widget_text’, ‘do_shortcode’); Just place it in your function.php file. Then you can place shortcodes in Text Widget … Read more

Overriding Attributes values in Shortcode Plugins

Try not to use capital letters in the shortcode attributes, use for example [wi_form product_name=”php” product_price=”888″ ] where: add_shortcode( ‘wi_form’ , ‘wi_form_func’ ); function wi_form_func($input) { extract(shortcode_atts( array( ‘product_name’ => ‘Java’, ‘product_price’ => 1000 ), $input)); return $product_name . esc_attr( $product_price ); } or this: add_shortcode( ‘wi_form’ , ‘wi_form_func’ ); function wi_form_func($input) { $input = … Read more