Add stylesheets and js to template files when shortcode is used

put wp_enqueue_script() in your shortcode handler. add_shortcode(‘myshortcode’, ‘my_shortcode_handler’); function my_shortcode_handler($atts) { wp_enqueue_script(‘my-script’, plugins_url(‘my-script.js’, __FILE__), array(‘jquery’), ‘1.0’, true); // actual shortcode handling here return “bacon flavored shortcode here”; } this definitely loads the my-script.js file for me. it gets loaded in the footer though. i don’t think there is a way for it to load conditionally … Read more

how do i remove posts from a WP_Query so the pagination is right?

Rather than querying all posts and then only displaying those that match the criteria, query for posts that match the criteria. WP_Query allows you to do just that with its meta-key/meta-value attributes. For instance, to get posts where the custom field unreleased is to ‘false’, somewhere before the loop: global $wp_query; $customField = array( ‘meta_key’ … Read more