The second parameter of your shortcode function is the content. So rewrite the function:
function shortcode_call_to_action( $attributes = NULL, $content="" )
{
$stylesheetdir = get_bloginfo('stylesheet_directory');
if ( '' === $content )
{ // use a default text if there is no content
$content="default text";
}
return "<div id='call_to_action'> <img src="https://wordpress.stackexchange.com/questions/58438/$stylesheetdir/images/call_to_action.jpg" alt="" />
<p>$content</p>";
}
If the user writes …
[call_to_action]Custom text[/call_to_action]
… the parameter $content
in your function will be set to that text.
For more details see the Shortcode API.
Related Posts:
- Solution to render Shortcodes in Admin Editor
- How to display random users with avatars
- Enabling shortcodes for custom fields
- Creating a table from shortcode avoiding wpautop for each row
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Stripping shortcode from custom excerpt function
- how to create shortcode in wordpress
- Display random text from a file with the WP built-in AJAX API
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Problem with extract() with custom shortcode
- Shortcode to insert menu in page body?
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Adding body class when post contains a specific shortcode
- Function to show only first instance of shortcode
- creating shortcode to pull json array
- Pass Shortcode Attribute to footer Script
- Detect Safari desktop browser and include the detection in a shortcode
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- Display gallery on top before content
- List child pages of specific page using shortcode
- How to extract the variables out from “add_shortcode” function?
- Display first name of logged in user?
- WordPress shortcode attributes for database SELECT?
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Shortcode inserts paragraphs before and after executing shortcode
- Display post shortcode content in the sidebar?
- Using shortcode content with nested shortcode
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- Setting youtube size in functions.php
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Add button to kitchen sink toggle
- Excerpts are not displayed by a shortcode on category pages
- check if the user is owner of current page
- shortcode help require
- Optimizing a WordPress site
- Use html inside shortcode function
- Shortcode parse error – wrong syntax
- wp_nonce_field is breaking form for reasons unknown
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Function shortcode – Set Parameter
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Echoing function into WordPress NextGen gallery
- Output loop to function return?
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- How to include any template using Shortcode fuction?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- Need to convert image url to a Base_64 data url with wordpress function..
- dynamic site link for future migration in echo do_shortcode()
- How to create shortcode with html and php content?
- Shortcode question
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- show all the posts thumbnails
- Problem with shortcode inside a shortcode
- Need help making a short code work
- Display a list of random terms from custom taxonomy with shortcode
- Load templates, pass arguments, and render output from functions.php
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- Customizing the wp_video_shortcode output with add_filter
- Probleme shortcode with list author
- Last updated posts shortcode in functions.php
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- Shortcode to insert default text and change one word throughout it?
- Shortcode Initialization in a Custom Theme
- Show users last read posts for each user?
- Hide disclaimer from summary excerpts
- HowTo: Add wrapper to columns shortcode?
- Function not receiving string from shortcode
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Custom shortcode with do_shortcode and substr
- Shortcode to eliminate and replace with
- Can I use a function to return HTML and the result of another function?
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Expanding a function to call a plugin or show a link
- Trying to the deduce shortcode from a function
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- using enqueue_script in a shortcode isn’t working
- Run function from parent on child site
- Gallery Shortcode Function Help
- Echo custom field value in shortcode function
- Shortcode Variations?
- Shortcodes not outputting in correct divs
- Custom shortcode not being included in content paragraph [duplicate]
- Creating mixture of shortcodes to use in the visual/text editor
- PHP error in shortcode [closed]