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)

28
votes
4answers
6k views

Where to put my code: plugin or functions.php?

Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php? There are many cases and many debates about that topic, mostly because there are ...
1
vote
2answers
2k views

Shortcode always displaying at the top of the page

I'm using a shortcode to pull in different loops via the loops-name.php. For some reason it is always at the top of the page. I googled it and using echo instead of return causes that problem but with ...
1
vote
1answer
247 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 ); ...
6
votes
2answers
21k views

How to customise the output of the WP image gallery shortcode from a plugin?

We're building a plugin that displays posts, and we also want to display the image gallery when it is used in a post. However, we need to limit the number of photos displayed? Is that possible?
4
votes
2answers
471 views

Show shortcode without executing it

I am trying to display code in my WordPress page and it isn't working. Everything I read says that you should be able to just use pre tag with code tag and it would be good but when I try to display a ...
2
votes
2answers
2k views

Redirect function inside a Shortcode

I am developing a free plugin for connection a external support system to WordPress to be able to authenticate users on WordPress. For this, currently from the external system, the user is sent to ...
1
vote
2answers
2k views

How to make shortcode to hide selection of text from post or page?

is there any shortcode or a plugin that will add new quicktag, like this example: [hidemytext]some hidden text[/hidemytext] and any text inside those tag is hidden from the post or from the page. ...
10
votes
4answers
16k views

How to manually fix the WordPress gallery code using PHP in functions.php?

It's been talked many times that Wordpress outputs some really bad code for the built-in gallery function. This is the core code responsible for the gallery output (in /wp-includes/media.php): ...
22
votes
7answers
8k views

Conditionally Loading JavaScript/CSS for Shortcodes

I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but ...
4
votes
1answer
316 views

How to return loop contents

At times, I need to return the output of a loop (usually with WP_Query like in this example) for use in a shortcode or with a filter on the_content. The following code that uses object buffering ...
5
votes
1answer
934 views

Using preg_replace to separate gallery from the_content?

In a Wordpress theme, I need to separate a gallery from the rest of the_content. I think one could do that with get_the_content and preg_replace but it's a little beyond my skill level how to actually ...
4
votes
2answers
3k views

Why might a plugin's 'do_shortcode' not work in an AJAX request?

tl;dr: Contact Form 7's shortcode doesn't work in an AJAX request when called with do_shortcode functions.php add_action('wp_ajax_ps_get_survey_form', 'ps_get_survey_form'); ...
-2
votes
2answers
2k views

How can I make all gallery images to open in a new window?

How can I make all gallery images to open the high resolution image in a new window?
5
votes
2answers
769 views

Use AJAX in shortcode

I have the following code to the shortcode to display a random quote. Question: how to make a button display a new random quote? I mean, that would hit the button and show you a new quote (without ...
5
votes
2answers
2k views

do_shortcode() within Admin Page

I'm using a few plugins that have shortcodes ... however, instead of creating a public page for the content, I've created some new pages within the admin using add_menu_page and I need to know how to ...
1
vote
3answers
171 views

Shortcode outputs at the top of the_content

The shortcode produced by this function - a list of all sites in a multisite - outputs above the content in the loop, no matter where it is placed in the editor. I've looked at the other related ...
12
votes
5answers
3k views

How to include code only on specific pages?

I'm learning about plugins and shortcodes. I noticed that when I activate my plugin its code gets loaded on all of my pages-- even pages that don't have my shortcode. (I don't mean content vs. admin ...
0
votes
3answers
2k views

Automatically added brs and paragraphs?

Here's my very simple shortcode: function box_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'width' => 'auto', 'height' => 'auto', ...
0
votes
3answers
163 views

Using shortcodes in PHP

I'm trying to use shortcode in my page, I'm starting with a simple test. In functions.php: function HelloWorldShortcode() { return '<p>Hello World!</p>'; } ...
0
votes
2answers
355 views

How do I create shortcodes for my wordpress themes?

I have seen many professional wordpress themes for sale that have shortcodes built in with which you could easily make posts like this: [alert_box]This is an alert box which based on this short-code ...
6
votes
2answers
307 views

current_shortcode() - detect currently used shortcode

In a plugin class I want to provide simple fields for public data: email, phone number, Twitter etc. The list can be extended. See the plugin Public Contact Data on GitHub for details. To keep the ...
3
votes
3answers
3k views

Add new “Insert Into Post” button with another function

Problem: Add a hook that automatically adds a short tag to video attachments when inserted from the Media Library (video) tab: Update: This works under the 'Media Library' tab — and doesn't break ...
1
vote
2answers
1k views

PHP error with shortcode handler from a class

Currently i am using the following generic flow for adding the shortcode for a plugin. class MyPlugin { private $myvar; function baztag_func() { print $this->myvar; ...
5
votes
1answer
3k views

What does extract( shortcode_atts( array( do?

The codex says shortcode_atts() combines user shortcode attributes with known attributes and fills in defaults when needed. The result will contain every key from the known attributes, merged with ...
1
vote
2answers
830 views

The result of a shortcode appear BEFORE page content

I have a page, with a shortcode that get all the post from a categorie and put after the content of the page. For no apparent reason, the result of a WP_Query() in the shortcode APPEAR ALWAYS at the ...
4
votes
2answers
2k views

add_filter and changing output captions of image gallery

I'd like to change only one output of native WP Gallery (in media.php) On Smashing Magazine (link) author advises to change whole gallery_shortcode function. But I wondered if is possible to change ...
3
votes
1answer
334 views

How do i link gallery thumbnails to different url's using the wp native gallery?

Is it possible to link each gallery thumbnail if i use the built in WordPress native gallery?
2
votes
1answer
294 views

Getting the count of a shortcode that is nested

Let's say I have nested shortcode where the outmost shortcode is just HTML but the inner one is the one who displays the data. [outer_shortcode][inner_code url="#" title="Hello"][/outer_shortcode] ...
2
votes
3answers
515 views

Nested shortcodes

I'm using 2 plugins in my wordpress blog - WP-Members and Dropbox Folder Share. I want to do something like this: [dropbox-foldershare-hyno link="[wp-members field="some_link"]" ver_como='lista'] ...
0
votes
2answers
168 views

How to link to a alternative page in CSS

I have a wordpress site and I want to be able to completely change a page that is displayed based on the browser size in my Custom CSS, so that if it is over 1500 pixels it loads a completely ...
5
votes
2answers
5k views

How to add multiple buttons to TinyMCE?

I've followed a tutorial on Nettuts on how to add a custom button to TinyMCE (http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/) It works great and all, but i want to ...
3
votes
4answers
4k views

How to check if a shortcode exists?

I'm using do_shortcode function to add shortcode in my template. But i would like to check if that shortcode exists before display them. I mean like this If (shortcode_gallery_exists) { echo ...
2
votes
2answers
990 views

Organizing shortcodes. How to display all of them and their attributes?

1. My shortcodes I've developed multiple shortcodes for my own theme, I'm loading them in functions.php like this require_once (MY_URL . '/bartag_shortcode.php'). Here's an exemplary bartag ...
5
votes
2answers
688 views

Create custom [sourcecode] shortcode, the right way?

What I want to do Sharing code in posts on WordPress is quite a pain with all the HTML escaping to take care of. So, I plan to enclose code in posts within a custom shortcode called [sourcecode], as ...
5
votes
2answers
3k views

Check if post/page has gallery?

I'd like to run some code only if a gallery (inserted with the [gallery] shortcode) has been inserted into a post/page. I did the following: gallery_shortcode($post->ID) ? $gallery = 1 : $gallery ...
4
votes
1answer
1k views

How to paginate wordpress [gallery] shortcode?

I am using wordpress gallery shortcode [gallery] I was wondering if there is anyway to paginate them without using a plugin.
0
votes
2answers
1k views

Stripping shortcode from custom excerpt function

I'm using the following function to create a custom excerpt for my homepage and categories pages so I can do it by character count and have a custom "read more". However, I have captions shortcode ...
0
votes
1answer
799 views

How to display a shortcode caption somewhere other than the_content

I want to disable shortcode captions for posts in one of my themes, and display the content elsewhere, such as in a sidebar. The images aren't uploaded to wordpress, but they're linked-to using the ...
2
votes
1answer
602 views

nested Shortcode doesn't work

Shortcode: [permalink][title][/permalink] Output: <a href="foobar">[title]</a> Wordpress shortcode API sais, it's correct: http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes ...
1
vote
1answer
1k views

do_shortcode inside AJAX callback

I have an AJAX callback function inside my functions.php file, which displays posts in a specific category. add_action( 'wp_ajax_ajaxified_function', 'ajaxified_function' ); add_action( ...
1
vote
3answers
643 views

stray <p> elements

I coded a wordpress shortcode for columns that basically inserts html via a shortcode. Problem is that wpautop adds stray p elements that renders the code invalid. To test put this into your ...
2
votes
1answer
83 views

Execute shortcode only in another shortcode

I wonder if it's possible to do a shortcode only in another shortcode. For example I got following code pieces: [heading]some pricing page[/heading] [pricing_box] [heading]Some title[/heading] ...
2
votes
3answers
966 views

WordPress gallery 'post_gallery' filter doesn't work with feeds?

We can use the post_gallery filter to modify/replace the default WordPress gallery template (AKA output code) to suit our needs. But this doesn't seem to affect the markup in RSS feeds. No matter ...
2
votes
2answers
2k views

How to call shortcode function directly and pass $atts

I am using the Media Library Categories plugin. It does not have much documentation, so I have concluded the way to implement it would be using the shortcode [mediacategories categories="6"]. I want ...
1
vote
2answers
769 views

Wordpress Gallery shortcode: Display one category ID only

Good Day. I am using a Gallery shortcode in my wordpress site to display images. Problem is that I wasnt the gallery to show only images from a certain category, for example category id 35. How do I ...
1
vote
2answers
1k 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
2answers
877 views

Why Won't my jQuery Play Nice with Wordpress?

Code in question here: http://pastebin.com/PN29WKNq It worked on the HTML page I tested it on. Its supposed to add "display: none" to the content divs and then add "display: block" when the ...
0
votes
2answers
124 views

Shortcode won't execute

I've created a shortcode using my limited knowledge, google, and stackexchange to do so. But when I load the page, it loads above the page contents and appears as html text. (shortocode text) ...
0
votes
1answer
1k views

Loading shortcode with ajax

I'm trying to load a slideshow if the browser is a certain screen size - i.e. I don't want the slideshow to load on smaller, mobile screens. The slideshow plugin provides a shortcode: <?php echo ...
0
votes
1answer
856 views

conditional shortcode not working

I'm using a plugin, NextGEN gallery, to display photos. Each gallery from this plugin corresponds to a different sub-page, so I'm using conditional shortcodes to assign the right gallery to it's ...