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.

721 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
1answer
2k 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 ...
5
votes
1answer
139 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
0answers
81 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
1answer
34 views

Changing a function in function.php to a shortcode - for listing categories of only a certain post type

I'm trying to create a shortcode that can display a list of categories. However, it should: First, limit the results to a specific post type (based on shortcode usage) then check to see if category ...
3
votes
1answer
1k 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 (...
3
votes
2answers
292 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
78 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
1k 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
0answers
270 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 ...
2
votes
0answers
30 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
1answer
19 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 ...
2
votes
2answers
2k views

Wordpress shortcode doesn't working on HomePage

What I want to do is make my Home Page. I can do it this way: Create a page and insert my gallery from plugin with that code [wonderplugin_gridgallery id=1] Set that page as HomePage. BUT THAT IS ...
2
votes
0answers
71 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
64 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
3answers
1k views

Can I use a Shortcode output as an HTML attribute value?

Within a span, the shortcode output works: <span>[sola_testimonials_count type='all']</span> Result: <span>5,205</span> But as an attribute value, it doesn't get parsed: &...
2
votes
1answer
507 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
1k views

Can A Shortcode Get HTML/Text From Content And Return It Twice With Added HTML?

I'm trying to cut down on some work for myself and I was hoping someone might know if this is possible. These are images setup in a slider that shows a text overlay on the image on the next slide in ...
2
votes
0answers
500 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
189 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
1answer
33 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
27 views

WordPress function not being called from jQuery method

I’m very new to WordPress Plugin Development. I’ve been learning and developing my plugin for around 2 weeks now. My plugin is supposed to be a retrieve a question from the WordPress database and ...
1
vote
1answer
46 views

Shortcode To Display Post Custom Field Value Inside Excerpt

I want to create a shortcode that pulls value from a custom field of a post and returns that value inside excerpt. I already have a function for the custom value: function geo_name_function( $atts ) { ...
1
vote
0answers
16 views

shortcode in snippet plugin not work

add_filter( 'woocommerce_product_tabs', 'wpb_new_product_tab' ); function wpb_new_product_tab( $tabs ) { // Add the new tab $tabs['test_tab'] = array( 'title' => __( 'Size ...
1
vote
0answers
18 views

How can I escape a section of my page which contains multiple shortcodes?

For testing purposes I often test multiple shortcodes on the same page and examine the results. However I would like to display the short codes being tested. There are a number of websites dealing ...
1
vote
1answer
850 views

AddToAny shortcode in the loop

I try to add addtoany shortcode in my custom loop page but the shared link stays always the same for each posts in the loop. <?php global $post; echo do_shortcode('[addtoany url="' . ...
1
vote
1answer
38 views

Missing image in gallery shortcode in custom feed

I have problem with custom gallery shortcode and missing first image in each gallery block. For example: [gallery ids="1,2,3,4,5"] show only 2,3,4,5 pictures. This custom shortcode is part ...
1
vote
1answer
26 views

How to exclude category ID from Looper in Wordpress

I'm trying to exclude 2 (and potentially more) ID's from my loop, that displays all categories that have posts. The category ID's i'm currently trying to exclude are 1 and 19. I'm very new to PHP but ...
1
vote
0answers
96 views

Shortcodes — Using add_action, add_filter in the shortcode

A client wants the following: User clicks on a specific button which takes them to a partner's site. If this is their first time clicking the link, they need to accept terms and conditions. If they'...
1
vote
0answers
12 views

Add a specific part of current category page url to shortcode

I have the following URL: website.com/category/xyz, where xyz can be hundreds of different words. I use a table plugin for displaying my content all throughout the website, and I want it to filter me ...
1
vote
0answers
95 views

How to display data from custom table in wordpress phpmyadmin

Thanks in advance could anyone here help me, I would like to display the value from the phpmyadmin database in wordpress, The value was stored from the dropdown form and I want display that value in ...
1
vote
0answers
18 views

Calculating a large number of MYSQL queries as customshort codes, slow

I am using wordpress and building a dashboard. There are a lot of complex MYSQL queries that I am running in order to return results from the DB. I am returning these as custom short codes in ...
1
vote
1answer
332 views

How do I display "Hello username" if logged-in on the homepage

I am trying to show the name of the currently logged-in user in a small text like 'Hello, username!'. I tried to do this, but it doesn't work: <p class="vam"> <?php if(...
1
vote
1answer
254 views

How to add an automatic refresh in Wordpress for a Page/Post or an embedded OneDrive/Excel HTML Code?

I have added an embedded Excel sheet on my website's home page. It is always displaying live data which is changing all the time. But when me or my colleagues view that page, they need to refresh the ...
1
vote
0answers
200 views

How to fix wrong attribute error for Visual Composer Grid Builder?

Hello I am facing this issue in editing media grid layout of Visual Composer V6.2.2. Below is the error I am getting Fatal error: Uncaught Exception: Wrong attribute for 'vc_single_image' shortcode. ...
1
vote
0answers
2k views

shortcode to display woocommerce cart total

I just hit a stumbling block. I'm currently using the <?php echo WC()->cart->get_cart_total(); ?> function to output the price of the products in cart. However, the resulting output was ...
1
vote
0answers
18 views

Orderby is working with one query but not with other

I'm using a shortcode to show some price boxes. I use a CPT with a custom field called 'posicion' which has a number that I use later to customize the loop. This is the code: <?php if ( ! defined( ...
1
vote
0answers
71 views

How to force that styles are enqueued in the header?

I have a plugin processing a shortcode, that needs specific styles. For this I used wp_enqueue_style. As I just need to enqueue the CSS upon certain parameters of the shortcode, I call ...
1
vote
1answer
28 views

Making a Template for a CPT created by a plugin

Good day, I'm currently working with a new plugin which creates a custom post type for different rooms and I'm trying to create a custom template using Toolset, but other content is automatically ...
1
vote
0answers
233 views

Shortcodes not working in category or tag description

when Yoast plugin is enabled shortcodes not working in category or tag description I used this and this article and add these codes to the function but nothing change please help me. add_filter( ‘...
1
vote
1answer
25 views

Wordpress shortcode for a section Template

I have made a Section Template called section-bachelorscholarships.php in the Folder frontpage in the Theme Folder and I have put this Code <?php while ( have_posts() ) : the_post(); ?> ...
1
vote
0answers
18 views

Populate shortcodes with table data and get next row

Let's say I have a database table wp_myplugin_cars that looks like this: id name color make -- ---- ----- ---- 1 Peter Red Ford 2 Jo Blue Nissan 3 Brian Silver ...
1
vote
1answer
276 views

Running shortcode with variable that is modified

I am a newbie to wordpress ... please help ... cannot get this code to work ... the [datatable} shortcode is a plugin shortcode (so it does exist) Worpress page: <label>Client ID Nr</label&...
1
vote
1answer
489 views

creating html reusable blocks via shortcodes

I'm using a really simple and fast theme in order to reach a good speed score, so i'm not using any visual composer, but writing my own sections in pages via html i have some sections and cta that i'...
1
vote
0answers
119 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
65 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
1answer
27 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
33 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
850 views

Place a URL parameter value inside a Wordpress short code

I would like to retrieve a URL parameter value and place it inside a shortcode so that so that it is handled as a variable, eg, http://example.com/?source=http://example.com/media/myfile.pdf ...
1
vote
1answer
188 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
250 views

How do you stop a shortcode from firing in the editor?

I created a custom short code that includes creating an on page table along with a few other things. But the short code is loading in the editor as well, and it is causing errors and preventing me ...

1
2 3 4 5
15