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 add a shortcode button to the TinyMCE editor?
- How to get last_updated and newest_blogs in WP 3.0
- Placement of Code in Plugin for hooking `save_post`
- Add get_option to jquery
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- Executing my function once on a specific time
- Anonymous Postings
- Using a function to change favorites listing
- Custom widget doesn’t save values from dropdown box
- Replacing global wp_query
- How to get specific string/value from an array? php [closed]
- How to create a plugin that includes all the other plugins?
- Why is it important to check for isset and is_array before checking in_array in this example?
- Execute a function when the entire page is displayed
- Is there any way to inject text onto pages?
- Want to modify a Plugin – Tweetily – Can I make it tweet a Custom Field instead of Post Title?
- How to add custom function to pluggable.php
- Shortcode do not return the right data in post
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- Is admin section completely customizable in terms of styling?
- Do_shortcode before send email content
- How to use a shortcode of a plugin in another plugin php file
- Echo custom admin field into a is_single()
- Bootstrap carousel – Using shortcode inside enclosing shortcode
- Am I using an action hook correctly?
- Cannot access variables within a widget
- Replace code in plugin template
- Remove the ‘Press This’ Tool
- How to delete remain data in WP database after deleting custom post via admin interface
- How to use ‘Event Manager Shortcodes’ plugin via the php code? [closed]
- Sync roles across several plugins
- WordPress Convert queries to slashes using function.php