2

I'm using has_shortcode() to detect a shortcode, it works but not at all. If I put this specified shortcode inside another one the has_shortcode() function stops working.

has_shortcode( $post->post_content, 'slider' )

For example:

[2col] //left column
[slider]
[2col_next] //right column
[slider]
[/2col]

The has_shortcode() function won't work in that case but if I use [slider] shortcode without [2col] it works perfect. This refers to every shortcode. I'm pretty sure that there's nothing wrong with my shortcodes.

1 Answer 1

3
$page_id = get_queried_object_id();
$page_object = get_page( $page_id );
if ( strpos($page_object->post_content, '[/slider]') )
1
  • Function 'get_page' is deprecated since 3.5.0 use get_post() instead. Commented Aug 28, 2020 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.