The shortcode uses ‘postfix’ and ‘postfix_singular’, which can be used in your code in a few ways. You can pass them directly in your do_shortcode()
call: echo do_shortcode('[rt_reading_time postfix="minutes" postfix_singular="minute"]')
, but that doesn’t help when you want to use translations. For that, you can use sprintf()
to create a string that gets passed to do_shortcode()
as a parameter.
Example:
$shortcode_call = sprintf(
'[rt_reading_time postfix="%1$s" postfix_singular="%2$s"]',
esc_html_x( 'minutes', 'minutes plural', 'plugin-slug' ),
esc_html_x( 'minute', 'minutes single', 'plugin-slug' )
);
echo do_shortcode( $shortcode_call );
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Best collection of code for your 'functions.php' file [closed]
- Shared functionality in plugins and themes
- Remote upload file to server B
- Checking if an attribute exists in a shortcode
- Autogenerate wordpress shortcodes using array?
- WooCommerce create new product and add to cart on form submit
- Shortcode display outside the div
- Post source link plugin – small modification
- Shortcode under a Shortcode Multiple times Possible?
- Modifying Footnote Plugin for Descriptive Title Attributes
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- Trying to count the total number of paragraphs inside a blog article
- Debugging Technique Question re: functions.php
- Override the filter from plugin in child theme
- May i Use ShortCode in Template?
- How to modify shortcode attributes with data from current post
- Prevent shortcode from being wrapped in tags
- Input with spaces in Shortcode attributes overwritten by defaults
- Edit Yoast SEO breadcrumbs output [closed]
- Adding Shortcode to Text Widget
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- creating html reusable blocks via shortcodes
- Nested shortcode functions accessing variable
- Best place for short bio,image and button [closed]
- How do I apply style to each category of a list?
- What is @Action in WordPress?
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Plugin Development – Functions or Hooks?
- Return multiple values in a shortcode attribute
- Shortcode Attributes to Return different $_POST
- Overriding an Array in a Plugin’s Class/Function from functions.php
- shortcode – multiple instances of same parameter name in one shortcode instance
- strange shortcode error: does shortcodes requires any dependency?
- Change Header (Logo) Based on Login
- how to change wp-admin url using function file
- Add the_post_thumbnail_url to a shortcode in function.php
- same user role or copy the user role to be same as the other role
- Adding a Tag Parameter / Filter to My Shortcode
- Call javascript functions from each page
- grab or load text on demand
- How can I replace content on site generated from plugin without changing plugin
- Rename Smart YouTube’s httpv back to http for all posts
- Elementor Pro display featured image on section -> style -> image using shortcode
- How to keep plugin (media-sync) running even the tab is closed?
- implement custom roles in custom plugin
- How to get current cart values using WC_Shortcodes?
- Post source link plugin – small modification
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Adding discount functionality to the cart
- How to assign a specific service to a specific provider based on location
- Precheck fields when I add a new post
- Get Shortcode output to database for static post_content
- working code, not working – Plugin Dev
- save short-code in my custom plugin settings problem missed something
- Place content inside the Post Loop
- Find all strings between an enclosing shortcode
- Hide some shortcodes on posts from back-end
- Conditional required fields for WordPress Contact Form 7
- wordpress Shortocode running twice?
- Posting code inside the post instead of in the template file using shortcode
- do_shortcodes() isn’t working
- Integrate Razorpay quick payments plugin with contact form7 plugin
- WordPress: code structure
- How to Add Extra Text In WordPress Title Before Post Publish
- How to disable plugin capability : “create new category”
- Product customizing quiz – quiz adding products to the cart
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- How to get next day date of a specific day
- Disable plugin only for one post
- Free paypal cart solution [closed]
- Are there action hooks for comments?
- Help with WP Business Directory Manager Plugin?
- Add filter on html tags,attributes on specific function in wordpress
- Plugin that provides the [edit] shortcode?
- Which plugin can do horizontal scrolling of RSS feeds in WordPress [closed]
- When I try to de-activate any plugin it gives error “Warning: call_user_func_array() [function.call-user-func-array]”
- Wp-query Order By problem
- Text change in Advanced Customs Fields [closed]
- I changed .live() to .on() but change is not reflected on the server
- Custom shortcode for displaying user based on a role parameter
- WordPress Plugin Insert Html Code with Shortcode
- wp_dequeue_script for a Plugin
- Need to replace Currency Shortforms
- wp_enqueue_scripts
- IF condition based on wp_remote_get output
- shortcode not return any thing in Gutnburg
- get specific value of a array | PHP
- How to get specific string/value from an array? php [closed]
- How to make a dynamic css class whose name changes every visit to confuse scraper
- How to change shortcode’s default theme?
- Plugin onclick button activate other plugin
- wc_get_template new template does not showing up
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- WordPress Stock Update Programatically
- Loading a plugin’s js file from functions.php
- Custom API plugin to execute 3rd party API to retrieve data
- Is there a way to convert shortcodes to html content?
- Loop in elementor custom widget not working
- 5 PHP Fatal error: Uncaught ArgumentCountError (Cannot Find)