You must not use use echo
or print
in a shortcode function. The echoed string will be printed out immediately when the content is processed, which is almost always too early.
So in your function you should just return the string without using echo
:
function swh_woocommerce_store_credit_shortcode() {
$store_credits = swh_woocommerce_get_store_credits();
return "<span style="display: inline;">Remaining Credit:</span>" . wc_price($store_credits);
}
Related Posts:
- How to add stylesheets only to pages with specific shortcode?
- Hide/show content starting in the middle of a paragraph
- How to add ‘class’ attribute into shortcode [audio]?
- How to link to a alternative page in CSS
- Video size and border radius using a shortcode
- Is it possible to ignore the first Line Break in a preformatted Div from a shortcode?
- How can I included CSS to a page or a shortcode? [closed]
- Two different inner shortcode under shortcodes or multiple nesting of inner shortcodes
- Make shortcode’s Bootstrap CSS override the theme’s CSS, how?
- the_excerpt displaying code inside style tag
- How to fix transparency in product sliders / featured products on home page?
- Loading shortcode stylesheet only when shortcode is in text widget [closed]
- How to Convert Shortcode into a link?
- Why are you using add_action for shortcode?
- How to get URL param to shortcode?
- Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation
- How to display the site name in a WordPress page, or post
- Native “playlist” shortcode random playing… How?
- How to display the names of users from a specific group with a shortcode?
- shortcode for logo image
- Stop strip_shortcodes() stripping content inside shortcodes
- How do i link gallery thumbnails to different url’s using the wp native gallery?
- Gallery shortcode menu order fix no longer working on WordPress 4.0
- How to save a shortcode in a Gutenberg custom block?
- Is shortcode_unautop() broken?
- Some doubts about gallery shortcode in WordPress
- Can a shortcode function this way
- Dynamically create shortcodes using add_shortcode and a callback
- Passing attributes to shortcode dynamically
- How To Add Perfect Apostrophe And Quotation Mark In WordPress Posts?
- Stop parsing shortcodes
- How can I make a shortcode from this code?
- Meta tags in shortcode
- Adding PHP/HTML code inside page from custom template
- shortcode javascript not working on custom template file inside theme folder
- shortcode get thumbnail size
- Shortcodes Keep Wrapping in
- Stop auto formatting in shortcodes
- Get URL Param Plugin and Inserting Result in Widget Code
- Problem with using custom shortcode with ACF WYSIWYG field
- Preserve shortcode content formatting
- Populate shortcodes with table data and get next row
- Running shortcode with variable that is modified
- Reloading a Mediaelement audio player
- Shortcode is not processed when added to option field using wp_editor
- How to apply an ID to Shortcode Embedded iframe
- How create a Shortcode with hover and complex options
- Adding Shortcode Values to wp_head
- wp_list_pages shortcode jumps above previous content
- Retrieving post excerpt as a shortcode
- Using $this from child class inside shortcode function
- Insert PHP code via shortcode?
- What is the correct syntax to append a URL using a shortcode for an iframe?
- Shortcodes in RSS excerpts
- How to trace shortcode to its functionality
- shortcode issue in the_excerpt
- If else with shortcodes
- Using shortcodes to communicate my page design
- enqueue script with get_shortcode_regex
- Use Contact Form 7 with Ajax
- How to get_post_meta in a shortcode in excerpt on archive pages
- WordPress upgrade adding additional quote marks to shortcode output
- How to build a shortcode for tabs
- Creating tabs shortcode
- SImple Example To Update User Info From Front End [duplicate]
- get_posts not working on homepage?
- Wrap template code with shortcodes
- my form does not insert any data in the database
- Using a WP shortcode in Homepage
- i want to show a modal when user lands on home page very first time
- Hide download option video shortcode
- WordPress Shorcode Display hierarchical taxonomy [child, parent]
- Gutenberg running code only available in front end within shortcode
- Insert HTML in content property and render it using shortcodes
- Redirect per shortcode if user is logged in
- Logout user if click on a custom page link
- Shortcode Attribute not defined
- Add Shortcode to ::before class
- Second attribute of shortcode is not changing why?
- Is Post-Author-Id shortocde
- Load next post by ID on a single page
- Plugin Shortcode value in post
- Add catagory attribute to custom shortcode
- Woocommerce Filter Main Loop by Tag [closed]
- Shortcodes: override a shortcode / change shortcode on the fly
- Class variables in shortcodes
- Separating Custom Template logic
- Remove width and height attributes from [gallery] output
- Shortcode for sectors
- How to not show shortcode contents if cart is empty?
- woocommerce Product shortcode create [closed]
- Help with Shortcode Functionality
- Shortcode Site include in a other
- Why is my ajax live search not working when i use a shortcode to call it?
- How do write this type shortcode? [closed]
- WordPress functions.php shortcode is not working [closed]
- My first WordPress shortcode just returning []
- WordPress shortcode select option not working [closed]
- I have the query code but not the shortcode
- wordpress how to sort posts on custom data with plug-in “Search & Filter”