[wp-hackers] checking if post has shortcode, before header is output?

scribu scribu at gmail.com
Fri Oct 23 23:02:08 UTC 2009


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


More information about the wp-hackers mailing list