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.
2,763 questions
0
votes
0
answers
24
views
do_shortcode Escaping
Please tell me how to escape the widget shortcode.
There is a function:
if (!function_exists('foo_do_shortcode')) {
function foo_do_shortcode($name, $attrs = array()) {
$special_chars = ...
-1
votes
1
answer
70
views
Wordpress shortcode JSON content has the quotes replaced by curly ones
I am trying to pass JSON content in a shortcode. But the double/single quotes are getting replaced by corresponding curly quotes. The result string cannot be decoded by json_decode for syntax error.
...
0
votes
1
answer
59
views
How to display a function inside shortcode tags
I need to display a function inside shortcode tags, but my function displays outside shortcode tags. How could I display my function inside shortcode tags?
my function:
function myFunction()
{
...
0
votes
1
answer
48
views
What's the syntax for embedding a Goggle sheet in a shortcode?
I want to embed data from a Google sheet in a Wordpress page. As far as I understand, the easiest is to do it inside an iframe, but that requires that I buy some plugin. Alternatively, one can use a ...
0
votes
1
answer
64
views
Disable / hide example preview using elementor editor on page with shortcode
Hello wordpress developers.
I have created a plugin that allows me to insert content on a page by using a shortcode, the content is rather long since it is an list of data.
When editing the page with ...
1
vote
1
answer
71
views
How to use Shortcodes?
I have created this shortcode in my child theme's function.php:
function display_product_stock_with_text() {
global $product; // Access the global WooCommerce product object
if ( ! is_product(...
1
vote
1
answer
64
views
Using a shortcode to get User Emails by role as specified in the shortcode, need help to allow for multiple roles
I have the following working code:
function get_emails_by_multiple_roles ( $atts ) {
$user_args = shortcode_atts ( array (
'role' => 'role' ,
), $atts );
$users = get_users( $...
2
votes
1
answer
112
views
How to create a three column blog layout with a single query and with three different classes?
I am trying to achieve the following layout :
I have created a shortcode for this but I am not getting the desired result. Can anyone guide me where I am getting it wrong. Here is full shortcode. ...
1
vote
0
answers
52
views
Custom Plugin not Displaying in the Website Production environment (Divi)
I built a custom plugin for a website Using Divi and I am facing a problem right now getting it to display in the production environment of the website. Here are the details:
Since you can't really ...
0
votes
1
answer
84
views
I have a php function with a shortcode to add share buttons, but I'm having an error!
I use a php function to create and add share buttons to specific places through a shortcode. It work's fine, but I'm getting this error:
Warning: Array to string conversion in ...142-custom-shortcodes....
0
votes
1
answer
299
views
Array to String Conversion warning in shortcode
I have a shortcode that I have been using for awhile that is suddenly causing a warning in WordPress 6.5 the error is "Warning: Array to string conversion in ... on line 109" - line 109 is ...
0
votes
1
answer
71
views
Getting the wrong featured image on archive page
I assigned my posts archive to a site on settings -> reading.
I added a post thumbnail to this site, and i want to show the image with a shortcode i have written in my plugin. The problem is, that ...
0
votes
2
answers
90
views
Shortcode to show author role on the author archive page
I have an archive page to show each author domain.com/author. On the archive page for an author domain.com/author/john-doe I want to display few information like name, e-mail address and role like ...
0
votes
1
answer
36
views
Nav Menu Short code Not working When non Login
I have made a toggle button with short-code for dark/light mode code below
function dark_light_toggle_button_shortcode() {
ob_start(); ?>
<!-- new button -->
<div id="...
1
vote
2
answers
763
views
wp:shortcode works in block theme template file but not PHP include file
Block markup generally works in included PHP files. I prefer to use PHP includes in many cases as I can do more interesting things with it than I can with a template file (.html). I've just ...
-1
votes
1
answer
70
views
Display the progress of post achievement with percentage against target in wordpress dashboard
I have a cpt called "movie", and I set a target for writers to make 50,000 posts in 6 months. The question is... can I make a percentage of the results of the number of recent posts against ...
0
votes
0
answers
42
views
add a meta value to the shortcode twice
I would like to build a shortcode looks like below.
[employee_session trigger=session-popup-1 trigger_type=id in_dialog=1 employee=1]
[employee_session trigger=session-popup-2 trigger_type=id ...
0
votes
0
answers
33
views
Products are displayed only in the admin area
I have a code:
$products_query_params = array(
'post_type' => 'product',
'product_cat' => 18,
);
return new WP_Query($products_query_params);
I need it to get products. But it works ...
0
votes
1
answer
358
views
How do I edit text color for shortcode?
I am trying to learn web development and using WordPress to make a site. I have Event Calendar, and Event Tickets Plugins. The Event Tickets Plugin uses short code to generate a checkout page after ...
0
votes
1
answer
474
views
How to create blocks from shortcodes?
I want to create a shortcode of myself that outputs “blocks”.
Level 1: Setting a pure text
I know how to do a simple shortcode. Let’s take this example.
add_shortcode( 'greet', 'myNiceShortCode' );
...
0
votes
1
answer
44
views
php codes ruins shortcode structure
I'm trying to use shortcode in index.php but when I use PHP code in my shortcode, it displays out of shortcode structure.
this HTML code works
<?php echo do_shortcode('[myshortcode label="...
0
votes
0
answers
54
views
How to add a shortcode for an image in the following function
This is a function by Tobias Keller for PRG Pattern Link Masking where title shortcode is link text. How то add image shortcode alternatively instead text ?
$use_prg = new prg_pattern();
class ...
0
votes
0
answers
33
views
How to trigger shortcode loaded by CSS
My theme has an option to display the tagline in logo area of the header (tagline added using theme Site Identity settings)
Using CSS I can supplement the tagline with additional content (words etc).
...
1
vote
1
answer
112
views
shortcode causes broken paragraph tags
I'm learning how to use short codes but I don't undrestand why WordPress keeps rendering broken paragraph tags.
I created a file called wp-content/themes/twentytwentythree/templates/single.html with ...
0
votes
1
answer
2k
views
get_the_ID() retrieves same ID on Gutenberg's Query Loop
I'm using Gutenberg editor and I want to add a shortcode (using XYZ PHP Code) that uses the post id to retrieve certain ACF value.
I'm editing the home page where the last blog posts are shown, but I ...