The main issue with the code snippet is this line:
function randomComment_handler($post_id) {
Check out the Codex on add_shortcode()
and see if you can find the error.
Spoiler: It should be like this:
function randomComment_handler( $atts, $content = NULL ) {
ps: You should also avoid using extract()
, use $atts['post_id']
instead.
Further consider adding the third parameter to the shortcode_atts()
function.
Related Posts:
- Solution to render Shortcodes in Admin Editor
- Use AJAX in shortcode
- Include PHP file in Content using [shortcode]
- Shortcode producing headers already sent error
- Enabling shortcodes for custom fields
- How to use get_media_embedded_in_content function
- Shortcode with parameters inside parameters
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Display random text from a file with the WP built-in AJAX API
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Problem with extract() with custom shortcode
- 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
- 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
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- 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
- shortcode help require
- Optimizing a WordPress site
- Help With Creating Shortcode
- 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
- 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
- Woocommerce checkout field
- 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()
- Need a method to prevent WP from adding in between my shortcodes
- 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
- 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
- Function to function shortcode help [closed]
- 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
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Hide disclaimer from summary excerpts
- 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
- 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
- Set thumbnail from URL, by grabbing image in functions.php
- Shortcode to output get_header not working
- restrict access to specific urls on a specific period of time
- using enqueue_script in a shortcode isn’t working
- Gallery Shortcode Function Help
- Add title & subtitle to shortcodes
- Echo custom field value in shortcode function
- Shortcodes not outputting in correct divs
- trouble with passing class method data to outside function
- Get term count on a category page
- How do grab the main loop, with conditions, and output via shortcodes
- Display function from functions.php in tag.php
- PHP error in shortcode [closed]
- multible shortcodes (for differnt values) with one function