If you wanna show the content in sidebar if current post content has the shortcode then you should try has_shortcode
function. Here is a demonstration-
$content = get_the_content();
if( has_shortcode( $content, 'your-shortcode' ) ) {
// The content has a [your-shortcode] short code, so this check returned true.
}
Hope it helps.
Related Posts:
- Split Content and Gallery
- Retrieve each widget separately from a sidebar
- How to return loop contents
- Adding ‘current_post_item’ class to current post in the loop
- How do I get the attributes of a short code from a post?
- Return vs Echo Shortcode
- as a shortcode within the loop?
- Adding shortcode closing tag after a loop
- What are the disadvantages of using global variable?
- Displaying terms based on loop posts?
- Missing image in gallery shortcode in custom feed
- Shortcode with a foreach and arguments
- Output loop leveraged shortcode twice on one page
- Custom Loop Using Shortcode in Custom Page Template
- Shortcode in posts called by ajax is not working
- is_active-sidebar loop
- Trying to get property of non-object in shortocde
- Query posts only with actual text content (not including shortcode or images)
- How to put a block of code between [shortcode][/shortcode] in do_shortcode()?
- Exclude current post ID from loop in sidepbar.php
- How can I pass additional params to a shortcode while in a loop?
- Get a Post Loop based on Logged in User information into a Shortcode
- How to add pagination in Terms
- Split Content and Gallery
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- Have multiple loops on a page appear after/between page content
- Using shortcode within shortcode with dynamic variable
- Variable not working in sidebar loop
- How wp maps urls into files
- Do I need to use The Loop on pages?
- the_content and wp_link_pages
- the_title(); works in a page template, outside the loop. Why?
- Page template not displaying
- the_widget() and widget’s ID
- How to get_template_part using AJAX?
- How can I modify the loop from a plugin without wiping out other filters?
- Complex query and posts pagination
- Loop in Related Posts WordPress
- Conditional query that displays on Woo product attribute pages
- Custom post type appearing within the previous one on archive.php
- How to inject posts from certain category on home page
- Showing sticky posts with get_posts()
- single.php – how to mark current page in the loop
- How to order by multiple fields using standard query_posts?
- Get 1 more post in loop
- Pagination not working in category listing [duplicate]
- Category links including all posts
- Hiding a row in the loop if empty
- How to display first post
- Pagination on custom post type on front-page.php
- get_template_part() Not Working in Loop
- get_delete_post_link() inside Loop stubbornly returns nothing
- Using variable in WordPress loop as criteria
- WordPress Alphabetical Sort Loop Issue
- Get_template_part() problem with the_content()
- Multiple instances of Featured Image Thumbnail As A Background On Homepage
- Altering “posts_per_page” for defaut loop
- Why doesn’t ‘continue’ work in page?
- Fetching posts from wordpress function in ajax
- Saving return value from the_author_posts_link()
- how to run loop in function.php that sends email based on specific conditions?
- loop inside a loop : search for posts in the same category
- How to sort a loop after most viewed
- How to declare a variable in a loop and make it available in the template file
- WordPress posts loop not displaying all posts on blog
- get_page_by_title not working inside fucntions.php
- How to use single.php output in function.php
- Bootstrap tabs are not being clicked in WordPress loop
- Get a specific size from wp_get_attachment_image_src
- WordPress + Isotope: how to give different widths to each entry?
- hide woocommerce tab if empty
- pages shortcode filtering by category
- Url outside the loop
- How to filter get previous post function by meta value DESC and post date DESC?
- Show other category posts in single.php
- Why does it loop twice?
- Cant pull in featured Image
- Custom Looping of WordPress Posts
- how to place Post and page content side by side
- Add specific class to featured posts
- Link Button url count php and wordpress
- ACF field not appearing correctly in loop
- Posts are being displayed from old to new, in ascending order
- Loop in taxonomy for terms and post
- WordPress Tags in class
- Query counting excluded category on paged loop
- modify default HAVE_POSTS() Loop without inserting new variable (i.e. $loop->HAVE_POSTS)
- Display articles related to a custom field on a page
- Changing the loop w/o killing category links
- Custom loop page with post navigation
- Pages with a loop (index, archive) are loading the first image as post_thumbnail
- Loop output for custom plugin [solution found]
- An action that runs after each post in the loop on index/archive page?
- Modify my code – which takes the first sentence of the post and use it as a h2 tag – to work outside the loop
- Getting post id in for loop
- Different style for first two (sticky) posts
- WooCommerce – Checkout suddenly stops working [closed]
- Want to images load first then title in WordPress loop
- How to add a continuous number to HTML tag attribute value inside The Loop [closed]
- WordPress Not Sorting By Custom Field