Your issues aren’t shortcode-related, just some PHP syntax problems. I suggest enabling debugging so you can see PHP errors being generated.
Opening <?php
and closing ?>
php tags are for switching between html and php output. See escaping from html in PHP documentation.
A function can only return
once, as it immediately ends execution and exits the function. See return
in PHP docs.
It also couldn’t hurt to familiarize yourself with strings and the proper use of single and double quotes.
function shortcode()
{
$input_examples = get_option('sandbox_theme_input_examples');
return '<img src="' . sanitize_text_field( $input_examples[ 'textarea_example' ] ) . '">';
}
add_shortcode('shortcode', 'shortcode');
Related Posts:
- How to insert image and text from admin panel throughout my theme
- Shortcode outputs at the top of the_content
- Combining shortcode and get_template_part
- Escaping quotes from shortcode attributes
- How to detect if a Shortcode is being called on a page?
- How to get current page title inside a page itself in a shortcode and in page content
- Short code to display a loop
- shortcode inside another shortcode
- How can I just get content inside a shortcode or just outside
- Custom Shortcode AJAX 400 Bad Request
- WordPress core responsive video not working with shortcode
- conditional shortcode not working
- Can’t seem to get [shortcode]s to work
- Wraping $content into link with shortcodes
- nested Shortcode doesn’t work
- Simple contact form with field validation
- Rewriting WordPress Gallery Shortcode with Bootstrap Carousel
- other shortcodes in Contact form 7 MAILS [closed]
- Remove empty p-Tags in Shortcode content before non p-Tags
- What is a short code?
- Wrap shortcode inside custom block
- Instagram URL is converted into oEmbed
- Shortcode with no attribute but has value
- Remove wpautop from specific shortcodes only
- Creating a shortcode based on users preferences
- Get a post’s thumbnail url or display default image in shortcode
- basic shortcode – Why 1st paragraph not wrapped in p tag, but 2nd is
- unwanted P tags in shortcode, delay wpautop not working
- Shortcodes and a list of IDs?
- Shortcode adding plugin output before post, instead of inline [duplicate]
- How to build a shortcode which can insert a query string into a DB table
- Visual Composer integration [closed]
- How to Modify WordPress Default Image Gallery Shortcode
- Include tags in the body of a post
- no content after shortcode
- Button Shortcode
- Remove shortcodes that are different (but same pattern) in each post
- Place a URL parameter value inside a WordPress short code
- Shortcodes in excerpts returning empty string
- Scripts for shortcode: concatenate or load separately? [closed]
- Print shortcode in defined area
- WordPress shortcodes are not working
- Conditionally Loading JavaScript/CSS for Shortcodes
- How to use/enable Pagination?
- Wrap Shortcodes and wpautop
- Shortcode called twice
- Favorite websites with shortened hyperlinks
- Best way to find all shortcodes that come with WordPress
- Using Variables in Shortcodes
- Default Attributes in Shortcode Not Working
- Replacement for gallery_shortcode function not taking all attributes
- Add JS in footer via shortcode?
- Shortcode syntax errors
- Passing variable in nested shortcodes
- Shortcode Always Displays Default Attribute Value
- WordPress Shortcode / Only works in classic editor, gutenberg error / invalid json response
- Do shortcode in template file
- How do I fit a function inside an opening and closing do_shortcode
- Pass instance number to shortcode child
- How to make shortcode which returns HTML?
- Add shortcode within the_content()
- How to create a custom shortcode for custom login form?
- Shortcode strips formatting and returns at content top
- do_shortcode within a shortcode
- tiny_mce_before_init preventing custom shortcode icon appearing
- Custom Fields – Boolean Display of True/False to Yes/No
- How to display NextGEN gallery in templates?
- Twitter bootstrap tabs
- jQuery Tabs in Shortcode API
- Echo Extra Shortcode HTML to wp_foot
- How can I use a plugin shortcode inside of a html form?
- Disable wpautop on Shortcode attributes
- remove shortcode pagination for specific url referrer
- Third-Party API – PHP Fatal Errors Paired with http_request_failed / cURL error 28
- Shortcode PHP file for two conditions passed when do shortcode
- Using within a shortcode
- update_metadata() appends shortcode data for every page refresh
- How do I point bloginfo(‘stylesheet_directory’) to my parent theme?
- Gallery shortcode is empty but magically creates a gallery
- Add audio file to post using custom term meta field as link [closed]
- Display tags cloud from a specific category ID with a shortcode
- Shortcode appeared twice on page, one time before content, one time where it’s really called
- How to list child pages with excerpts, e.g. [child-pages depth=”1″ excerpt=”1″]
- Video shortcode outside WordPress not working with IE and mediaelement’s Flash fallback
- Inserting a variable into a shortcode inside php
- Display title of child pages in shortcode
- Shortcode for Admin Theme Option?
- Clarify: Enqueueing scripts within shortcode only loads in footer?
- What makes a placeholder resizable in Tinymce?
- Shortcode templates
- Create plugin/function to catch XML-data via Shortcode
- Why My slider shortcode display above header
- Shortcode conversion to hrml when post is published
- Shotcode error on functions
- Shortcode for displaying the user’s first name?
- Can I prevent wordpress adding and tags to autoembeds
- Shortcode – Display inline icon before text [closed]
- 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?