Try this instead:
function has_shortcode($shortcode="") {
global $post;
// false because we have to search through the post content first
$found = false;
// if no short code was provided, return false
if ( !$shortcode ) {
return $found;
}
if ( is_object( $post ) && stripos( $post->post_content, '[' . $shortcode ) !== false ) {
// we have found the short code
$found = true;
}
// return our final results
return $found;
}
Related Posts:
- restrict access to specific urls on a specific period of time
- Solution to render Shortcodes in Admin Editor
- Use AJAX in shortcode
- Include PHP file in Content using [shortcode]
- WordPress function like is_category for subcategory? is_subcategory?
- deregister scripts on certain page
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- How to display random users with avatars
- Enabling shortcodes for custom fields
- How to use get_media_embedded_in_content function
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Shortcode with parameters inside parameters
- Creating a table from shortcode avoiding wpautop for each row
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- Entirely Different Functions.php per Page?
- Function to echo (or display?) wordpress tags in the head section
- is_home() not working in functions.php file
- If is_single in functions.php
- Shortcode of a function
- show all the posts thumbnails
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Problem with shortcode inside a shortcode
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- 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
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- Javascript file loads only on homepage, not on other pages (404 not found error)
- page shows short code not output
- Probleme shortcode with list author
- Function to function shortcode help [closed]
- Last updated posts shortcode in functions.php
- Enqueue script if not page template
- I want to display the sku in the product pages of my EDD website
- is_product_category(‘Services’) not working
- 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?
- Function for Sticky Post on Categories causes issues with 404 behavior
- use add_action in a shortcode (gravity form – WordPress)
- Unable to declare AOS library in functions
- Shortcode displaying outside the div [duplicate]
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- method to fetch entire tag list on archive.php
- How to retrieve image IDs from shortcode content?
- Display list of pages that contain a certain string within the slug
- Hide disclaimer from summary excerpts
- HowTo: Add wrapper to columns shortcode?
- Function not receiving string from shortcode
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Adding an IF ELSE to a function
- Custom shortcode with do_shortcode and substr
- Shortcode to eliminate and replace with
- how to display featured image for single post for a specific category
- Can I use a function to return HTML and the result of another function?
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Load CSS conditional on custom field is present
- Expanding a function to call a plugin or show a link
- Trying to the deduce shortcode from a function
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- Shortcode to output get_header not working
- admin-ajax.php nulls all php variables
- Change conditional tag in wordpress without editing the core files
- using enqueue_script in a shortcode isn’t working
- Run function from parent on child site
- wp_enqueue_scripts called twice?
- Gallery Shortcode Function Help
- Add title & subtitle to shortcodes
- Echo custom field value in shortcode function
- Shortcode Variations?
- Shortcodes not outputting in correct divs
- shortcode inside post called by ID does not render as expected
- Custom shortcode not being included in content paragraph [duplicate]
- trouble with passing class method data to outside function
- How can i hide content if not friend in Buddypress? [closed]
- 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
- Creating mixture of shortcodes to use in the visual/text editor
- PHP error in shortcode [closed]
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false
- multible shortcodes (for differnt values) with one function
- post_content return zero!
- How to make my logged-in user-role shortcode displaying name instead of slug?