A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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.

609 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
115 views

Can I create customizer setting that can handle plugin shortcode?

Can I create a customizer setting which will handle a shortcode from a plugin? Do I violate and rules or guidelines in WordPress theme development? If it's possible what is the best way to sanitize ...
4
votes
1answer
1k views

Hide/show content starting in the middle of a paragraph

I need to be able to hide/show arbitrary content (paragraphs, lists, maybe pictures) based on a user clicking a link. This is easy enough, but I am running into a lot of problems trying to add this in ...
3
votes
1answer
20 views

Export User Info to CSV from Front End

Trying to export to CSV from WordPress front end. Here is what I have so far. I was able to export to CSV from the admin area, but for some reason I am unable to export from the front end. What am I ...
3
votes
2answers
163 views

Calling shortcode in wp_localize_script strips result

I am working on adding some functionality on a Wordpress plugin which after a certain click needs to call on some shortcode through ajax. What I first attempted was to call the shortcode inside of ...
3
votes
0answers
52 views

Can I strip HTML tags in the “Compare Revisions” screen?

I am building a CMS for content editors that have zero tech savvy. They currently use a system called NewsCred that allows them to compare revisions much like how WordPress does when you visit /wp-...
3
votes
0answers
71 views

Tinymce shortcodes within shortcode contents

I am using wp.mce.views.register to create a simple view for my shortcode in the tinymce editor, this works fine but i am looking for a way to have "nested" shortcodes e.g. [column_3] [info_box] ...
3
votes
1answer
2k views

Customizing gallery shortcode in 3.5

I'm trying to customize the gallery shortcode using the new gallery system in 3.5 and I'm having a bit of trouble and can't figure out where I'm going wrong. This is what I've got at the moment (in ...
2
votes
0answers
23 views

Looking for a solution - slightly convoluted problem

OK so stick with me on this one... it's a little involved. I won't describe it all, I'll simplify things as best I can to the basics. OK so, on my wordpress site I have three text boxes (BOX1,BOX2,...
2
votes
0answers
70 views

Wordpress 4.7 Galery shortcode not working

my gallery shortcode is working wp 4.00 version but ı upgrade wp.4.7 not working how can i fix . why not working ? when i delete this function ,normal wp shortcode function not working . this is my ...
2
votes
0answers
59 views

How to make shortcode output display where I choose

There are tons of post about this, but in my case, i see no echo(so i can change for return) in the shortcode.php file of the plug in, i did not developed this plug in, i need to fix the problem that ...
2
votes
1answer
699 views

Change default settings used by gallery shortcode

I need to change the default gallery shortcode settings so that "columns" = 5 & "link" = 'file'. Which filter to add to the file functions.php? Source code: $atts = shortcode_atts( array( ...
2
votes
1answer
315 views

WP theme with Backbone

What would be the best way to insure that a Backbone WP theme cooperates with standard shortcodes and other WP plugins that include script and style tags in header and footer. I know Backbone plays ...
2
votes
1answer
911 views

Shortcodes not working in an AJAX call

I am using AJAX to load next set of posts on homepage. The posts load fine but the shortcodes are not rendered. I am trying to use the do_shortcode function on the content the ajax call fetches (...
2
votes
0answers
287 views

Is it possible to delay execution of shortcode output callback?

I have a problem : shortcode output callback triggered too early. /* Defined in plugin constructor */ add_shortcode( 'foobar' , array($this,'pre_render_routine')); function ...
2
votes
1answer
445 views

esc_attr not working in shortcode

I have a shortcode that outputs a block of html. One element in the block is an anchor tag with an image caption in the title attribute. Some of the captions I am using have double quotes in them, so ...
2
votes
1answer
703 views

Shortcode displays only default attribute values

For some reasons every shortcode, that I try to add to functions.php, displays only default attribute value and ignores what I specify in a post. E.g.: function my_shortcode( $atts ) { extract( ...
2
votes
1answer
177 views

Processing shortcodes in groups (separated by line breaks)?

The Project I'm working on a plugin to resize and embed rows of images using shortcodes that will be converted into <img> tags. In most cases there will be multiple images per row, and the ...
2
votes
2answers
696 views

Remove empty p-Tags in Shortcode content before non p-Tags

We build a media (based on bootstrap 4 media object) shortcode with the following syntax: [media img="https://via.placeholder.com/64x64.png"]<h5>List-based media object</h5>Cras sit amet ...
2
votes
1answer
27 views

Wordpress auto adds p to shortcode parameters

Wordpress auto adds p tags around shortcode parameters. Is there any way to stop this ? function minimum_working_example ( $atts, $content ){ extract(shortcode_atts(array( 'html' => '',...
1
vote
0answers
25 views

Wordpress Shortcodes.. printf is outputting a random number… Can't figure out WHY?

As the subject states... why is this happening? I have the following shortcodes registered so that the user can easily create a slideshow within their content and widgets. functions.php function ...
1
vote
1answer
14 views

Using shortcode content with nested shortcode

This is a shortcode example. [a][b]something[/b][/a] It should be used like this with do_shortcode($content); function a_shortcode($atts = [], $content = null) { do_shortcode($content); ...
1
vote
0answers
23 views

Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?

I am trying to embed a custom WP_Query inside a shortcode I have activated on one of my pages (created in Elementor). I have a Custom Post Type called 'inspector-profiles', and for some reason when I ...
1
vote
1answer
18 views

Shortcode multiple values

This is my data (example): var obj = { something:'custom' people:[ { name:'john', age:51 }, { name:'jenny', age:62 } ] } And I use such shortcode: [...
1
vote
0answers
20 views

Remove shortcodes that are different (but same pattern) in each post

I have unused shortcodes in my posts like the following: [wp-imageflow2 dir=NokiaN868MP176] [wp-imageflow2 dir=Nokia6303classic97] [wp-imageflow2 dir=LGOptimus3DCubeSU87026] How do I remove them ...
1
vote
1answer
32 views

Colon is Missing In My Website Url in Wordpress

add_action( 'init', function() { add_shortcode( 'site_url', function( $atts = null, $content = null ) { return site_url(); }); }); I'm Using The Short Code [site_url] and My Short ...
1
vote
1answer
12 views

Can't get custom posts of taxonomy to show

I have a custom post type called 'brand', with a taxonomy of 'brand-categories'. try as I might, I cannot find a way to display a list of posts in the current taxonomy. can anyone help? <?php ...
1
vote
0answers
40 views

AJAX and Shortcode with Parameters

I'm creating an ajax function which will display a filtered post. I used a shortcode to display the post. The shortcode has a parameter to filter its display. I have a category and a tag parameter. ...
1
vote
1answer
174 views

Custom Theme, Custom shortcode not working

ENV: WordPress version 5.1 / MAMP Pro php v. 7.2.14 I'm building a new, custom theme for a site that has an old, custom theme. The new site is just a single theme, while the old site has a parent ...
1
vote
1answer
253 views

How to create shortcode to display custom field value on a custom post type

in my ad site I was trying to create shortcode of some custom fields I created on a custom post type. I'll explain In the single post, there are the custom fields and are shown in a standard way in ...
1
vote
2answers
39 views

Shortcodes in excerpts returning empty string

I got this code: function ntt_movie_shortcode($atts, $content = null) { return 'TEST'; } add_shortcode('ntt_movie', 'ntt_movie_shortcode'); The shortcode works perfectly on a single page, but on ...
1
vote
0answers
23 views

add action only if gallery shortcode attribute is equal to?

I'm customizing the gallery shortcode. Now, when the user clicks on edit button as shown below: We can see the gallery modal like below: In the right sidebar, we can see the gallery settings. And I ...
1
vote
1answer
63 views

SEO Friendly URL on dynamic product page produced via shortcode

I have created a product page in wordpress, /product. This currently takes the id of a product /product/?id=123 The page has a shortcode that then fetches and displays the relevent data e.g. [...
1
vote
0answers
14 views

How to display all subpages and short by year

How can I display all child-pages and short by year in Wordpress For example: all subpages in 2016, 2017, 2018: • 2018: ----- Subpage A ----- Subpage B ----- Subpage C • 2017: ----- ...
1
vote
1answer
150 views

Possible to display shortcode based on the category?

So, aside from creating individual WordPress Category PHP Pages, I'd much rather have a functions.php command that would insert shortcode when a Category has been selected. How would I go about that, ...
1
vote
0answers
207 views

Reloading a Mediaelement audio player

I am writing a WordPress plugin (private and not intended to be publicly available) in which I am displaying a huge list of audio files (about a thousand) along with ONE audio player (like the one ...
1
vote
0answers
301 views

Shortcode function executed twice?

I use a shortcode function to do some processing as a callback from external service. I created a page, the only content of which is the shortcode. User is redirected to this page from external ...
1
vote
0answers
36 views

Shortcode Plugin to dynamically build a shortcode via `do_shortcode` not working

Basically I want to create a plugin that provides a shortcode for use anywhere. This plugin will query the user's preferences and render another shortcode/plugin with proper settings (to cater ...
1
vote
0answers
36 views

add_shortcode to capture URL screenshot not loading correctly

Hello I have a function as shown below to capture website screenshot, as well to be used as a shortcode in a text widget. The shortcode [metadata_website] is somewhat working, the issue i am ...
1
vote
0answers
122 views

How to render a custom post type template with custom fields using shortcode

I have a post type called "Milestones" which has several custom fields and custom a template to render it. What I am looking for is a way to return all the rendered output from a shortcode. The ...
1
vote
1answer
216 views

How can I render shortcode so that its not cached by Caching plugins?

I am developing a plugin and I don't want the output of my shortcode to be cached by popular WordPress caching plugins like W3Ttoalcahe, WPSuperCache, etc. Is there any way I can achieve that or ask ...
1
vote
0answers
312 views

Custom Shortcode: define cursor position/insertion point?

I have created a shortcode and TinyMCE plugin for a shortcode. Click the button, it inserts [my-shortcode][/my-shortcode]. But it adds the code and then the editor cursor is after the closing ...
1
vote
0answers
134 views

Custom shortcode outputs plain text instead of HTML at top of post

I am new to wordpress and coding and I need some help. I have a custom post type called 'endorsement' that would like to create a shortcode for that will output a list of posts sorted by a custom ...
1
vote
0answers
237 views

modify wordpress caption shortcode

I need to modify the Caption shortcode so that it renders the caption wrapper regardless if there is any caption text present. I've modified my Media content type with a custom field called Credit. ...
1
vote
0answers
73 views

Asynchronously render shortcodes in TinyMCE visual editor

I created an img shortcode (e.g. [img attachment="19"]) that I want to render in real time in TinyMCE visual editor. So, I created a plugin for TinyMCE that replaces the shortcode in real time. Here ...
1
vote
0answers
19 views

Making sure that a plugin's scripts and stylesheets are included for dynamicaly loaded content

I'm currently making a theme that uses admin-ajax.php to dynamicaly load pages and posts. Some of this content uses plugins like final tiles gallery and Video Embed & Thumbnail Generator. If ...
1
vote
0answers
45 views

Is using custom table to suit business needs instead of transients a big hit to page load speed?

I am working on changing the caching strategy to save the response of an API(which refreshes data in every 30 minutes). Among other things, I came across transients and their unreliable nature of ...
1
vote
1answer
297 views

Form action/link to render a plugin in WordPress front-end

I am new to WordPress and I'm wondering if anyone could help me understand how I should go for rendering the output of a plugin when a form of a widget is submitted in the front-end. I'm developing a ...
1
vote
1answer
77 views

Calling an attribute from a plugin shortcode

I'm using this plugin to show the reading time of my post: https://jasonyingling.me/reading-time-wp/ However, I have modified some stuff because I want to be able to use it with different languages ...
1
vote
0answers
22 views

Media added with shortcodes not “linked” with post

When you add Mediafiles (images, galleries, videos etc.) with the "Add Media Screen" in "Post Edit Screen" then the Attachment will get linked(parent_id) to the post/page. I don't know if this is ...
1
vote
0answers
329 views

Documentation for adding a tinyMCE view for visual live preview of custom shortcode?

I'm trying to add a WYSIWYG visual representation for a custom shortcode into the tinyMCE editor but I can barely find any information on how to do that. Researching the last few days resulted in ...