Simply don’t call return
more than once.
Just add your output to a variable:
$some_variable_name="mention the = at the beginning of this line";
$some_variable_name .= 'Take a look at the .Period before the = in this line';
$some_variable_name .= 'then add more lines always with the period';
// at the end of your shortcode function:
// if you want to echo something:
echo $some_variable_name;
// or:
return print $some_variable_name;
// If you want to just return it in code:
return $some_variable_name;
Also #1: Keep your variable names with lowerspace characters.
Also #2: In php, variables always have to use _
underline instead of -
dash.
Related Posts:
- Conditionally Loading JavaScript/CSS for Shortcodes
- shortcodes output before content [duplicate]
- WordPress adds br in between my shortcode
- Shortcodes, HTML tables, and multiple rows
- Does a shortcode with a single attribute have to use an array?
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- How navigation works in custom loop within shortcode?
- Use [shortcode=”value”] instead of [shortcode att=”value”]?
- I dont want to show shortcode in tag
- Post loop created via shortcode not displaying shortcode in content
- Pass shortcode variables to template
- Is it possible to add a repeater field to TinyMCE’s option window?
- Shortcodes: Pros and Cons
- esc_attr not working in shortcode
- Raw output (preventing wpautop)
- WordPress shortcode doesn’t working on HomePage
- Can’t understand $atts in functions?
- Are .MP3 files with capital letter extensions allowed in [audio] shortcode?
- How to handle shortcodes when using the JSON API
- Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?
- Add attribute to shortcode dynamically
- Execute shortcode twice in the same page
- How to parse this shortcode?
- Get Posts shortcode plugin and meta_query?
- Shortcode parsed incorrectly because of heredoc
- Shortcode “post_per_page” not working
- Shortcode is running in page editor
- Creating shortcode with parameter
- Video Shortcodes not working in WordPress
- Custom shortcode is not working in text widget
- Create shortcode in Child Theme?
- Get post object in shortcode function
- How to insert image and text from admin panel throughout my theme
- Use shortcodes in terms description? [closed]
- Adding to the_content or a variable from within a shortcode function
- How to add shortcode to HTML file (not showing on website)
- Custom Shortcode: define cursor position/insertion point?
- Shortcode: text content ends up outside html tags
- show shortcodes in editor
- Image Shortcode from ACF ID
- Page code showing in WP Dashboard
- echo do_shortcode just prints the shortcode name and not its content
- How to create an incremental list using shortcodes?
- Shortcode in my childtheme is not working
- Do shortcode that is inserted in a textarea is not displaying properly
- How to Make Archive ShortCode
- Are Shortcode Attributes Always Passed As Strings?
- Show form per shortcode
- wp_editor not rendering the shortcode
- Default WordPress shortcodes not working?
- How to make this shortcode work for post content wordpress [duplicate]
- Pass fileurl parameter into shortcode from Advanced Custom Fields
- stop WordPress removing shortcode from content [closed]
- caption shortcode using image alt as caption
- Shortcode arguments to another shortcode
- Sanitize or treatment of string in editor via shortcode
- Is it possible to handle two or more shortcodes in a single page?
- Toggle Shortcode Sanitize Title
- How to deal with WordPress bug: can’t use wrapped and unwrapped shortcode on same post
- Execute Shortcodes when submitting post
- Substituting value via shortcode
- Can’t render shortcode when html tag contains hyphen
- Auto embeds don’t work for attachment descriptions
- Shortcode to appear and show the date not code in Title and description of Social Media sites
- Not to escape a text
- how to add shortcode widget at end of main blog page
- Shortcode result appears above page content
- Pagination for custom posts loop
- Shortcode is not showing content when placed in editor (post_type = page)
- Modify [caption] shortcode so and are not used?
- How to set up posts per page on WP
- How to insert a short code into Contact Form 7 in WordPress that will call a function once the submit button is pressed
- How to Call Related Post based on Categories Inside Post Content with Shortcode?
- Unable to make shortcode, what is wrong?
- Multiple shortcodes only use attributes from one of the shortcodes on custom plugin
- Cannot modify class property from shortcode handler function
- Reusable Dynamic Taxonomy Shortcode
- How do i remove Business feeds Shortcode fatal error
- Can’t place endwhile in the loop properly in a shortcode
- How to reduce the image size inside an icon? [closed]
- How to insert visual compser post grid shortcode in a custom page template? [closed]
- Push Shortcode parameter to template
- latest posts shortcode with image
- Shortcode tags appear on mobile themes
- Video shortcode inside tabs shorcode NOT working
- Manipulated shortcode output
- Where is escaped the shortcode?
- How to add meta slider lite or other slider to main page header in pinboard theme
- Str_replace using shortcode with multiple changes
- Changing layout of defaul gallery output to masonry
- shortcode change variable base on user
- WordPress do_shortcode first iteration
- Add a short code to a plugin
- Add widget/shortcode to sidebar OUTSIDE of the theme
- How to remove https:// from shortcode generated url
- How to enable on custom shortcodes
- Nested ShortCode works inside the_content, but not outside of it
- Working with Shortcode, AJAX, Elementor
- How to exclude some cats from wp_list_categories using shortcut
- How can I create a shortcode that shows a list of categories on the single product page?