BB-Code-like mechanism by which strings enclosed in square brackets can serve as shorthand for longer and more complicated strings. These strings are processed by callback handlers, usually on page load, which replace the bracket enclosed string with the output from the callback handler.

learn more… | top users | synonyms (2)

1
vote
2answers
2k views

Remove width and height attributes from [gallery] output

WordPress automatically adds the width and height attributes to [gallery] shortcode images. How to delete these attributes? Something like this but for [gallery] output.
1
vote
1answer
1k views

Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?

I'm not sure if I've asked the question properly, apologies for that! What I'm trying to do is, output a <!--nextpage--> tag via a shortcode. But it doesn't work, I guess because shortcodes are ...
1
vote
1answer
4k views

How to call custom taxonomy categories with shortcodes

I've just had one questions solved over here: How to display posts from a single category within a custom taxonomy. Now I'm wondering how to take this code: <?php $args = array( ...
1
vote
1answer
130 views

Multiple loops on page only show taxonomy name of first loop

I have a page with a custom post type called 'books', with taxonomy 'booktypes'. The books are ordered/divided in a loop per taxonomy-item, and added via shortcode to the page editor like this: ...
1
vote
1answer
84 views

Set first oembed in post to a global variable or function

I have a function that gets the first oembed in the post. I got the code from this related post. add_filter('embed_oembed_html', 'my_function',10,4); function my_function( $cache, $url, $attr, ...
1
vote
2answers
98 views

Get shortcode from the content and display it in other place (in sidebar, for example)

I have a shortcode: [content_block] If that shortcode exists in content and has the attribute position=top, I would like to remove it from the content and display it in other place. For example, in ...
1
vote
1answer
330 views

Remove hyperlink on gallery shortcode

I use a gallery shortcode in my index.php (theme directory) to display 3 boxes of images. The images are fetched from my Media. <div class="well well-clear" style="padding-bottom: 0; ...
1
vote
2answers
477 views

What are the disadvantages of using global variable?

I am a newbie at WordPress. In my "recent posts" shortcode, I used global $post variable, because the_title() function was giving me page's title, not post's title. I am not exactly sure, but I ...
1
vote
1answer
328 views

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

I want to display a specific gallery (without a plugin = WordPress built-in gallery) inside a widget. I tried the shortcode [gallery ids="717"] but that doesn't work. Maybe a workaround could be ...
1
vote
1answer
269 views

Turn a snippet of HTML and PHP into a shortcode

the code is <div class="huili-relevant-left"> <a href="<?php echo get_post_meta($post->ID,"taobao_value",true);?>" hidefocus="true" target="_blank" ...
1
vote
1answer
466 views

wp_editor returns the shortcode and not render the output

I built a plugin, and I would like to use shortcodes in the integrated wp_editor. I'm using echo to display the content of the wp_editor, so I think that's the problem why I can't use the shortcode. ...
1
vote
2answers
865 views

Including javascript for a shortcode

I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads. I'm having issues trying to decide when ...
1
vote
3answers
2k views

Getting attribute value from shortcode

I have this shortcode [learn_more caption="something here:"] [/learn_more] I want to extract the caption value and remove other stuff. "something here:" This is the code that I have, but it ...
1
vote
1answer
809 views

How to handle shortcodes when using the JSON API

I'm wrangling a little logic problem: I'm making a single page WP theme which uses the JSON API for the content and Mustache style templates for the presentation... However, shortcodes? What would be ...
1
vote
3answers
5k views

How to Insert Shortcodes into Theme?

I have content locker plugin. For locking contents, im using this shortcode: [wp-like-locker] Your locked content here... [/wp-like-locker] and I need lock every post on my blog. How could I ...
1
vote
1answer
336 views

short code output too early

I'm trying to create a shortcode base on the following code: <ul class="filter"> <li>Filter:</li> <li class="link-store"><a href="<?php echo get_permalink( 23 ); ...
1
vote
1answer
937 views

check for shortcode in post/pages AND widgets AND template files

For the next version of my plugin www.mapsmarker.com I would like to output the plugin´s css and js-files only if the shortcode [mapsmarker ...] is used. For posts/and pages I already found this ...
1
vote
2answers
749 views

Display gallery on top before content

Is it possible to execute the gallery shortcode before any other content no matter where the shortcode is in the post HTML?
1
vote
1answer
1k views

extract shortcodes from string

i need a little help to with this issue: I have a string wich contains shortcodes like [shortcode data="1" data2="2"] How I can extract with regex? without wordpress system? Thanks in advance.
1
vote
2answers
2k views

Implement If-ElseIf-Else-EndIf with short codes

I have very little experience with WordPress and PHP, so I apologize in advance for syntax problems. I'd like to know if it's possible to implement If/Else logic as short codes. Something like: ...
1
vote
2answers
1k views

shortcode causing the_content() to return blank?

I have a shortcode that just retrieves some info from the options table in the database. For whatever reason, when the content reaches a certain character limit the_content() to return blank? The ...
1
vote
1answer
2k views

How do I hardcode a WordPress shortcode into my theme?

I am using WooTheme's Canvas theme and would like to "hardcode" in the [post_comments] shortcode into my theme. [post_comments] displays a comment link with comment count (ie Comments 10) in my post. ...
1
vote
1answer
326 views

May i Use ShortCode in Template?

Am Using Wordpress Blog.Here i want Use Tweetmeme Plugin.I want to show the output of the Tweetmeme Plugin to Customizing place(Side of the Post[Not Before or After]).The Plugin Creators are providing ...
1
vote
2answers
1k views

How can i remove the paragraph from shortcodes content?

If you have created shortcodes in Wordpress, you may have noticed that when you get the content of your shortcode, it's wrapped in html paragraph tags. I don't know why the progammers did that. It ...
1
vote
3answers
671 views

Get Posts shortcode plugin and meta_query?

I'm using Get Posts plugin to list posts with post type "project". I want to filter the list by two custom fields: year (ex. 2006) and state (ex. Completed). I added meta_query to the plugin's ...
1
vote
1answer
626 views

How do I combine my shortcodes?

Example I want combine shortcode for first paragraph and dropcap. function st_dropcap( $atts, $content = null ) { return '<span class="dropcap">'.$content.'</span>'; } ...
1
vote
3answers
169 views

Using a Shortcode to Replace Themes Stylesheet?

Is there a function to replace the active theme's stylesheet with a different one (not just adding a new one, but actually replacing the current one)? I'm developing a plugin, and using shortcodes ...
1
vote
1answer
2k views

Custom Post Type Loop within Shortcode

I'm really at loss as to why this isn't working: I am using a shortcode to display a query on a custom post type + taxonomy, this is the segment of it: // - arguments - $args = ...
1
vote
1answer
1k views

Pass variable to nested shortcode

I'm setting up a plugin with a nested shortcode, i.e. [ct_training_group] [ct_training] [/ct_training_group] Here's the catch: I use the [ct_training] code outside of the parent as well as ...
1
vote
2answers
34 views

shortcode get thumbnail size

How to get shortcode thumbnail size? my code get shortcode thumbnail size in functions: function thumb_medium( $atts, $content = null ) { return wp_get_attachment_url( get_post_thumbnail_id( ...
1
vote
1answer
68 views

Get shortcode attribute outside of Wordpress

Is there a clean way to get a shortcode's attribute value outside of Wordpress's default behaviour? I am working on a single script outside a Wordpress installation, where I only do ...
1
vote
1answer
112 views

Add attribute to shortcode dynamically

I'm looking to add an attribute to a shortcode used in a post dynamically. For example, say we start with: [shortcode-name] I'd like to add the "attribute=xxx" portion to the shortcode so it is ...
1
vote
1answer
148 views

Execute shortcode twice in the same page

I need help with a shortcode question. I have this code: add_shortcode("archive", "archive_render"); function archive_render($atts) { extract(shortcode_atts(array( "rientro" => "no", ...
1
vote
2answers
97 views

Shortcode API: How to get name that matched shortcode RegEx?

I am looking for a way to reproduce what is described in the documentation: An overloaded shortcode callback. According to the docs, the $atts array will contain the string that matched the shortcode ...
1
vote
2answers
68 views

Creating a shortcode based on users preferences

Background: Creating a dynamic shortcode based on user inputs. This shortcode should change the output of do_shortcode based on the fields the user selects. Example: On a page, a user selects ...
1
vote
1answer
145 views

Custom shortcode being executed when saving page in wp-admin

I'm working on a custom shortcode: [abuzz-store slug="woolworths" fields="description,level,phone" more="true"] The shortcode is working correctly on the website frontend. However, I can no longer ...
1
vote
1answer
58 views

'&' causes an error in my shortcode when I list the content of the page

I would like to list the specified pages with my shortcode, but the problems are with the '$' charachters. function get_page_func( $atts ) { extract(shortcode_atts( array( ...
1
vote
1answer
350 views

basic shortcode - Why 1st paragraph not wrapped in p tag, but 2nd is

I'm working on a basic plugin that adds shortcodes for columns, buttons, panels, ect. Nothing new here. I haven't altered wpautop in anyway; I've tried removing it and delaying it - no change. What ...
1
vote
2answers
425 views

Shortcode: display list of created shortcode in popup

I want to create a popup shortcode in admin panel. I already create the shortcode button and a popup on button click. I want to display in the popup (not in the shortcode button), all my custom ...
1
vote
1answer
393 views

has_shortcode() - how to detect nested shortcode

I'm using has_shortcode() to detect a shortcode, it works but not at all. If I put this specified shortcode inside another one the has_shortcode() function stops working. has_shortcode( ...
1
vote
2answers
2k views

How to parse nested shortcodes?

The nested shortcodes won't parse correctly: [row] [col size="6"]...[/col] [col size="6"] [row] [col size="6"]...[/col] [col size="6"]...[/col] [/row] ...
1
vote
1answer
145 views

Videos via the video shortcode are always 640px wide?

I've run into a particular problem with the Video Shorcode of WP. I can't seem to change the size of the player with the attributes of the Shortcode. This happens on multiple sites with multiple ...
1
vote
1answer
4k views

Woocommerce, ordering products by default on shortcode pages

In my woocommerce store I have a Sale Products page. In this page I use the shortcode to display the products on sale [sale_products per_page="40" columns="3"] In the store the products are ordered ...
1
vote
2answers
958 views

Call Shortcode inside another Shortcodes callback

I'm using a plugin that shows content only to specific user roles. This content is surrounded by a shortcode tag to make it invisible to other other user roles. Now I'd like to call other shortcodes ...
1
vote
2answers
531 views

Localize variable for multiple Shortcodes

I have this code for flexslider Shortcode add_shortcode('flexslider', function($atts){ global $post; $ids = explode(',', $atts[ids]); $uniqid = uniqid(); wp_enqueue_script( 'shortcode_flexslider'); ...
1
vote
1answer
113 views

How to generate CSS from a shortcode within a plugin

I'm struggling to generate CSS 'on fly' from a shortcode that is within a plugin using class. Here is the shortcode function: public function shortcode($atts, $content = NULL) { $data = ...
1
vote
1answer
266 views

IF statement in a do_shortcode

Is it possible to do a if statement in a do_shortcode? <?php echo do_shortcode("[table width='500'] " . if ( have_posts() ) : while ( have_posts() ) : ...
1
vote
1answer
37 views

detect when shortcode ran for the last time

I'm wondering, given this code: add_shortcode( $tag , $func ); Is there a hook I can use that will always be called AFTER the last time $func was called, but soon enough, so I can still call ...
1
vote
2answers
543 views

Place the page title into the short code

I have created a short code called [contianer-narrow][/container-narrow] which wraps your content in a twitter bootstrap class: .container-narrow the issue is that the page title is not included. is ...
1
vote
1answer
121 views

Shortcode for a link and thumbnail

<?php // Add Shortcode function blog_shortcode( $atts ) { // Attributes extract( shortcode_atts( array( 'id' => '', ), $atts ) ); // Code if (has_post_thumbnail()) { $url ...