« Return to Thread: checking if post has shortcode, before header is output?

Re: checking if post has shortcode, before header is output?

by scribu :: Rate this Message:

| View in Thread

Try this:

add_action('template_redirect', 'add_scripts');

function add_scripts() {
if ( ! is_page() )
return;

global $posts;

if ( FALSE === strpos($posts[0]->post_content, '[your_shortcode') )
return;

wp_enqueue_script(...
}


--
http://scribu.net
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

 « Return to Thread: checking if post has shortcode, before header is output?