Questions tagged [shortcode]

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.

Filter by
Sorted by
Tagged with
2
votes
1answer
1k views

Prevent add_shortcode from escaping a tag

In my plugin, I'm rendering a shortcode with some inline JavaScript. Wordpress seems to hate the closing CDATA tag (]]>), as it escapes it. I'm using CDATA blocks so as to render well-formed XHTML, ...
2
votes
1answer
727 views

Disable oEmbed for a Single Shortcode or at Least All Internal Links

Is there any way to disable the oEmbed functionality only for a specific call of the do_shortcode() function in just one script or if that is not possible can it be disabled for all the internal links ...
2
votes
3answers
1k views

Nested Shortcode Inside [caption] Doesn't Process

Captions in wordpress do not support nested shortcodes at the moment (v3.6). So, If I do write [caption]<img src=""> I love my [city][/caption] Where city is suppose to be processed but it ...
1
vote
1answer
152 views

Pass $this to function nested in another public function of the same class

I'm building a plugin using the WordPress Plugin Boilerplate by DevinVinson. I'm adding a public shortcode function for wich I will need some resources (js and css), I want to enqueue scripts (that ...
1
vote
1answer
6k views

change plugin shortcode function [closed]

i use a plugin that containing this code and i want to change the css and js and template.php location to be located in my template directory instead of plugin without editing the plugin files public ...
1
vote
2answers
829 views

How can I get the [video] shortcode to allow query string parameters?

Using WordPress 4.4.2 (latest version as of writing this) I'm trying to use the [video] shortcode to show a video on my site. If I provide a url ending with the filename.mp4 it works fine: [video ...
1
vote
1answer
2k views

<!--nextpage--> as a shortcode within the loop?

Anyone implemented this successfully? I want to include the <!--nextpage--> within a single post loop as a shortcode. I tried to echo it, the tag shows up but the post doesn't get divided into ...
1
vote
2answers
1k views

Add_shortcode as a Class to pass arguments to a function

Bonsoir, I want to pass shortcode attributes to my class in a form of an array and the name of my shorcode but in the wordpress codex doesn't says how could i do that, this is my code $atributos=...
1
vote
1answer
6k views

How to get current page title inside a page itself in a shortcode and in page content

When i add the <?php the_title(); ?> to a page template file it works and is able to pull the page title inside html tags however if i wanted to add <?php the_title(); ?> to a ...
1
vote
3answers
6k views

Run shortcode at certain resolution

I've gone a roundabout way of trying to ask a question about this here: Loading shortcode with ajax but figured it might be worth asking the fundamental question of what I am trying to do without ...
1
vote
2answers
35 views

Pros and cons of actions over shortcodes

I need to output some posts on some pages and I created shortcode: function show_foo() { // output stuff } add_shortcode( 'foo', 'show_foo' ); and I use it like this in templates: echo ...
1
vote
1answer
851 views

Debugging shortcode problems

I am trying to get some of the Miscellaneous shortcodes working properly on my website. In particular, I would like to use the pages shortcodes: [list-pages], [child-pages], [sibling-pages]. I am ...
1
vote
2answers
733 views

How to return a string that has a variable inside in a shortcode?

$output = '<p class="one"><small>'.$newsletter_one. '</small></p>' Generally, when we write short codes we publish HTML like the above one, and instead of echo use return ...
1
vote
2answers
851 views

has_shortcode for content added after the content

I added some shortcode after the content using filter, like this: add_filter( 'the_content', 'image_posts' ); but now that I run has_shortcode in another function, this returns false even though the ...
1
vote
1answer
3k views

Shortcode in Text Widget not working

Not sure why this is not working. I get no errors, but just shows nothing at all in the text widget. The shortcode works on pages and posts. WordPress version 3.9.1 add_filter('widget_text', '...
1
vote
1answer
283 views

How to check if this is the nth instance of a given shortcode in a post

Suppose I have a shortcode called [item], which I have used 20 times in a particular post. Is it possible, from within the shortcode handler function, to know what the numerical index of the given [...
1
vote
2answers
4k views

How to prevent tinymce macro from inserting nbsp;?

I've got the following macro button defined to wrap a selection in a shortcode in the wp_editor visual editor: (function() { tinymce.create('tinymce.plugins.ingredient_name', { init : function(...
1
vote
1answer
2k 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
0answers
67 views

NextGEN Gallery- using shortcode for different galleries on different pages [duplicate]

Possible Duplicate: conditional shortcode not working I have a salon website with a gallery page wherein the user must first select a stylist prior to viewing their individual gallery. I planned ...
1
vote
1answer
1k views

Visual Composer integration [closed]

I've installed Visual Composer on my own template. The thing is that is not rendering all it's shortcodes. <?php $post = get_post( $post->ID ); echo $post->post_content; ?> Is that code ...
1
vote
1answer
419 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
2answers
6k views

Remove images from get_the_excerpt

I'm using a custom function to create a shortcode that displays the latest blog post on the home page of a template. But I'm trying to NOT have it display any images. I know I can use the Advanced ...
1
vote
1answer
274 views

Shortcode with custom content attribute?

I am creating a shortcode for a client site that should display an image and a saying (mainly at the bottom of the page, but basically wherever the client wants to insert said image/saying). The ...
1
vote
1answer
79 views

Get returned variable from a function to add_shortcode function

I'm passing successfully an ajax object to the backend following this (the script in the JS really it does not matters because I'm getting it well): add_action( 'wp_ajax_my_action', '...
1
vote
2answers
502 views

Inserting shortcode [stream /] into a Text widget

hi i'm trying to insert a short code into a Text widget but all its doing it showing the code and not processing it. <?php echo do_shortcode(' [stream embed=false share=false width=500 height=560 ...
1
vote
1answer
203 views

Can't seem to get [shortcode]s to work

function register_shortcodes(){ add_shortcode( 'my_shortcode', 'my_shortcode' ); } add_action( 'init', 'register_shortcodes'); function my_shortcode( $atts ) { return "--my_shortcode--"; ...
1
vote
2answers
424 views

unwanted P tags in shortcode, delay wpautop not working

Like others, I'm having issues with WP adding unwanted p tags in my code. I have a shortcode I created that is to simply just spit out my javascript and html when I use it. Everything works fine ...
1
vote
1answer
238 views

Use [shortcode=“value”] instead of [shortcode att=“value”]?

With shortcodes that have only one attribute, it would be much easier from a content-editing perspective to use, for example, [icon="myicon"] instead of [icon whichicon="myicon"]. Is this possible in ...
0
votes
2answers
345 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 ...
0
votes
1answer
833 views

Stream Video Player does not work with do_shortcode()?

I have downloaded a plugin called Stream Video Player, which has a shortcode. If I put the shortcode into the content editor, it works well and it displays the video. However, if, inside a template I ...
0
votes
1answer
56 views

Correct way to pass information between seperate shortcode functions

I contain all my short-codes in (the equivalent of) functions.php. I want to have one short-code function share information in an object, and another able to access that object. The shortcodes may or ...
0
votes
1answer
289 views

Adding Image Count to Multigallery

Ok so I am using the [multigallery] function and it works fine, but one thing I want to add. Here is the code that I am using for the multigallery in my functions.php file function ...
0
votes
1answer
25 views

Is it possible not to define category on function.php and add the shortcode [shortcode cat=1] to display the products?

I have created a shortcode called home_slider. If I use [home_slider] then I will get the slider on my page which is working. Now my concern is, Is it possible not to define category on function.php ...
0
votes
1answer
149 views

Do not show child pages of child pages

I'm looking (without having to copy the whole code) that when the child page has child pages of it's own that it wil not show those child pages but still the parrent page 2 levels up. i played with it ...
0
votes
1answer
916 views

template_redirect to accompany with a shortcode

In one of my plugin's shortcode I'm handing user login / registration on the fly with a post submission. So the whole thing is happening within the shortcode like: <?php function this_shortcode() {...
0
votes
0answers
382 views

Custom field for default gallery

How I can add custom field in default WordPress gallery? in visual editor and in shortcode.
0
votes
2answers
3k views

Get shortcode attributes outside shortcode function

I'm writing a slideshow shortcode and need to grab the shortcode attributes in an external function so I can add the javascript to the footer. For example: add_shortcode('test','test_function'); ...
0
votes
2answers
171 views

Print shortcode in custom action hook not where the shortcode is entered

I have added a custom action hook into my theme. I want to be able to enter a shortcode anywhere in the_content() and have the shortcode print were the custom action hook is rather then the point from ...
0
votes
0answers
588 views

How to use shortcodes on a widget sidebar when doing an ajax call?

I'm trying to use a shortcode from Promotion Slider Plugin inside a widget when doing an ajax call. As said here, I could achieve it doing: add_action( 'init', function() { ...
0
votes
1answer
566 views

How to list all active and specific shortcodes in wordpress

I wonder how you can list specific shortcodes, for example with this code you get a list of all active shortcode tags: <?php global $shortcode_tags; echo '<pre>'; print_r($shortcode_tags);...
0
votes
1answer
156 views

How to protect own PHP code from Wordpress updates

I have written several own shortcode scripts which I place in the shortcodes.php file. My Wordpress installation is set to update to new Wordpress versions automatically, which is a good thing. But ...
0
votes
2answers
242 views

Specific loop in Shortcode

I'm making shortcode and I'm stuck here. Here is code: add_shortcode('service-shortcode', 'service_shortcode'); function service_shortcode($atts) { extract( shortcode_atts( array( 'title' => ...
0
votes
1answer
109 views

Add/echo div with Analytics-Code to function in functions.php

I want to do something special I think. I need to add a html-snippet with GA-Code to a function in functions.php. To do this I thought to add this piece of code: echo ('<div onClick="ga('send', '...
0
votes
1answer
879 views

Calling function from within functions.php returns unwanted value

I am trying to customize the output of the [gallery] shortcode to include comment count by this plugin: Facebook Comments for WordPress plugin I found a function by Zack Austin (shown below) that ...
0
votes
1answer
6k views

plugin shortcodes not working on custom theme- unsure how to fix

Live site. I've got a custom theme that is giving me slight issues with shortcodes- they don't work. When I switched back to the default theme, the shortcodes worked fine. What do I need to look for ...
0
votes
2answers
68 views

wp_editor in add_meta_boxes does not show gallery

I have added a meta box in the page edit section: add_meta_box('custom_section_box', 'Sections', array($this, 'section_box'), 'page','normal','high'); Within the box, there is a wp_editor call: $...
0
votes
3answers
8k views

How to pass multiple values in shortcode?

All I am using formidable plugin and on one page i need to use 5 shortcodes. [frm-entry-delete-link id=9 page_id=25 field_key=hsn108] [frm-entry-delete-link id=12 page_id=25 field_key=cp7pi] [frm-...
0
votes
2answers
160 views

How to make this shortcode work for post content

I have been trying but its not working. but if i try <?php echo do_shortcode("[mimo]"); ?> <?php echo do_shortcode("[mibaby]"); ?> it will work fine. But to apply it in post content ...
0
votes
1answer
56 views

Wraping $content into link with shortcodes

I'm working with shortcodes in WordPress and I struggle with one problem. I'm trying to wrap my $content into tags, but it doesn't work properly. So here is my shortcode function: <?php ...
0
votes
2answers
276 views

manipulate a plugins shortcode

I want to add some javascript directly below content, added by another plugin's shortcode. We are using the NextGen Gallery plugin and there are many articles containing the [nggallery] shortcode. I ...