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

How to parse this shortcode?

shortcode_parse_atts will give you managable information. $atts = shortcode_parse_atts( ‘[soundcloud url=”http://api.soundcloud.com/tracks/67658191″ params=”” width=” 100%” height=”166″ iframe=”true” /]’ ); You will get an array that looks like this: array(7) { [0]=> string(11) “[soundcloud” [“url”]=> string(41) “http://api.soundcloud.com/tracks/67658191” [“params”]=> string(0) “” [“width”]=> string(5) ” 100%” [“height”]=> string(3) “166” [“iframe”]=> string(4) “true” [1]=> string(2) “/]” } You can the … Read more

How do I add text in a shortcode?

hello you can try this // Add Shortcode function text_shortcode( $atts , $content = null ) { // Code return ‘<div>’ . $content . ‘</div>’; } add_shortcode( ‘b’, ‘text_shortcode’ ); The shortcode will be something like this [b] content [/b]

Remove hyperlink on gallery shortcode

Update: It looks like there exists an attribute link=”none” after all 😉 For example: So we don’t need to reinvent the wheel, like in my previous answers 😉 Previous: Plugin to handle link=”no” in the gallery shortcode: Here’s a demo plugin to add the option to remove the image links in the gallery. You can … Read more

Video shortcode – autoplay all videos

I ran into this problem while trying to make HTML videos behave like GIFs. WordPress’s built-in video player uses HTML video elements but does not allow videos to play simultaneously. Instead of using the default WordPress video player (which is best used for more standard video content), I chose to manually use the <video> element … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)