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
- Use AJAX in shortcode
- WordPress function like is_category for subcategory? is_subcategory?
- How to add attributes to a shortcode
- How to display random users with avatars
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Creating a table from shortcode avoiding wpautop for each row
- is_front_page not working in functions.php
- Stripping shortcode from custom excerpt function
- Formatting post content to exclude gallery
- Problem using is_single() to enqueue script from functions.php
- Conditional tag is_page with a custom post type
- Shortcode with custom content attribute?
- Shortcode to insert menu in page body?
- Passing HTML in WordPress Shortcode arguments
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- Post Pagination Showing Same Posts Every Page
- Custom Shortcode, functions PHP WP_Query loop
- Super simple shortcode not working
- How to extract the variables out from “add_shortcode” function?
- Enqueue scripts not working with if is page conditional tag in functions.php
- How do I redirect all 404 error url to Subcategory url
- How to get specified parent page title in my function
- Possible to display shortcode based on the category?
- Shortcode pagination not advancing
- Having issues with a foreach inside of a shortcode with ACF gallery
- Display post shortcode content in the sidebar?
- How add various functions within 1 conditional?
- How to get the index number of the posts?
- Using shortcode content with nested shortcode
- How to filter $content in shortcode function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Conditional Gravity Forms filter in WordPress Multisite
- Display gallery on bottom after content
- Has is_archived() for sites in a multisite changed with WP 4.7?
- WordPress Shortcode function display outside of widget
- check if the user is owner of current page
- shortcode help require
- Help With Creating Shortcode
- WP function won’t work on 404 template page
- Use html inside shortcode function
- Shotcode argument issues
- Exclude category from shortcode
- get_pages() Returns Only One Item
- Function shortcode – Set Parameter
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Use a shortcode to display custom meta box contents
- functions.php and conditional tags
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- issue with if/elseif in_array inside foreach loop display only one post
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- Need to convert image url to a Base_64 data url with wordpress function..
- How to create shortcode with html and php content?
- Tracking the number of shortcodes for a list?
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- 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?
- If is_single in functions.php
- Problem with shortcode inside a shortcode
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Display a list of random terms from custom taxonomy with shortcode
- page shows short code not output
- Last updated posts shortcode in functions.php
- is_product_category(‘Services’) not working
- Help using ShortCodes to style whole chunks of the post
- 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
- HowTo: Add wrapper to columns 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
- 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?
- 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
- Change conditional tag in wordpress without editing the core files
- Run function from parent on child site
- Add title & subtitle to shortcodes
- Shortcode Variations?
- shortcode inside post called by ID does not render as expected
- Custom shortcode not being included in content paragraph [duplicate]
- How can i hide content if not friend in Buddypress? [closed]
- Display function from functions.php in tag.php
- Creating mixture of shortcodes to use in the visual/text editor
- PHP error in shortcode [closed]
- multible shortcodes (for differnt values) with one function