That would print the stylesheet links into the footer. Works in most browsers, but is invalid HTML. You should hook into the action wp_head instead and check the post content for your shortcodes. Use a priority 0 to run earlier than the the action wp_enqueue_scripts.
add_action( 'wp_head', 'shortcode_check', 0 );
function shortcode_check() {
global $wp_query;
if ( empty ( $wp_query ) or empty ( $wp_query->posts ) )
return;
foreach ( $wp_query->posts as $post )
{
if ( FALSE !== stripos( $post->post_content, '[shortcodename' ) )
return add_action( 'wp_enqueue_scripts', 'shortcode_enqueue' );
}
}
function shortcode_enqueue() {
// enqueue scripts and stylesheets here
}
Related Posts:
- Turn Off Auto Update for Single Plugin
- Is there a way to use latex \cite{reference} in wordpress?
- How to check plugin compatibility before upgrading WordPress
- How do I unlock a post programmatically?
- Force Plugin to English Translation
- How to parse nested shortcodes?
- Custom wp_nav_menu output (displaying all child elements of top menu element in current branch)
- Is it possible to have screenshots in any other section rather than the screenshots section?
- Removing user contact methods works from functions.php but not from a plugin
- Subscribe2 Configuration
- Dynamic HTML not displaying at respective place
- I need to Remove this line
- Should I global $wpdb outside of any of my plugin’s functions scope?
- Filter or action hook to insert content on admin pages before tag
- How do I change the default WordPress e-mail ID for sent e-mail?
- How to create a word press user with hashedpassword
- Display specific WooCommerce products to different types of users
- Is it possible to set up multistore in Woocommerce? [closed]
- Leveraging WordPress Comments on Custom Plugin Object page
- Woocommmerce show SKU in cart page
- W3 Total Cache: Load CSS asynchronously for better PageSpeed score? [closed]
- Show HTML form before WordPress plugin deletion
- Redeclare theme’s function in a plugin
- Check if we’re viewing an event
- Show price with Geo IP location
- Menus, but not by theme location
- How to get 1 or 2 specific posts on top of my wordpress blog?
- Getting value from dymanic text variable into Contact Form 7
- className not populating in custom block
- Will Gutenberg Have a Negative Impact on Page Speed?
- How to export post 2 posts WordPress plugin data [closed]
- import posts with dutch/special letters
- WordPress metaboxes – textfield suggestion automatically populated
- How to tell which one of my plugins are paid or free?
- Would Gutenberg be considered a PlugIn?
- Is there a specific term for Plugins that are specified in a WordPress Post using Comments?
- Check if variable is set in filter
- Basic gallery plugin suggestion [closed]
- Child Themes and Updating Parent Theme
- How to write “alt” tag in image for wordpress code?
- How do I rename a category in the menu bar only?
- Wooslider custom css
- A plugin that downloads other plugins
- How to use template_include hook with form submission?
- Large amount image data transfer
- CMB2 field not showing on front end category page
- is it possible to hook every page style?
- translate “load more” button
- Redirect logged in user to somepage on every page view?
- Add the_post_thumbnail_url to a shortcode in function.php
- I need a lightbox plugin that will apply to gallery [closed]
- Override translation of 1 word
- merge wordpress plugins
- Plugin permissions for Editor role
- How to add an admin alert for missing plugins
- JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly
- Call javascript functions from each page
- After installing JetPack, can I delete the WordPress stats plugin?
- how to create hierachial taxonomy and manage under single post type?
- Button and Countdown overlapping mobile menu
- How can I disable new plugin and theme install, but allow updates?
- Dynamic URL Issue on SEO Scan
- Check if theme supports sidebar
- Change plugin descriptions
- update_option_{$option} not working (do function after options are saved)
- Looking for WordPress PDF Converter with Custom Templates?
- How get horizontal div instead vertical CSS
- Out of date plugins not showing ugrade link
- Use Case: Multiple Shipping Methods per Order
- Showing how many times is plugin activated or deactivated
- Can’t add or delete plugins – but I’m an admin [closed]
- WordPress Categories as a Grid
- Ajax response returns html code instead of user data
- get/show Last ID
- Why is WP template_include overwritting all templates rather than specified page?
- Building a Article Library within WP?
- What is the best practice for making a WP plugin that I want to develop responsive?
- Form tries to download a file on submit
- Undefined index – get_option
- Auto-login from backend
- Plugins don’t show up after renaming plugins folder
- How to prevent query strings persisting on certain page templates
- Use of apply_filter in plugin/widget class
- How to use wp_http with https-pages?
- Edit Buddypress Groups Activity Page Text [closed]
- GravityForms to Salesforce API, problem with people who leave out company [closed]
- Access to wordpress method inside of classes
- WordPress User Portal
- How to include a custom thumbnail with my WordPress plugin?
- ACF Plugin WP with list-group – Vimeo [closed]
- How can i display portfolio images in WordPress?
- Can anyone tell some online tuts for plugin development for beginner? [closed]
- Slider Plugins for header [closed]
- Custom priority with the_content filter based on user input
- Links not opening as they should. Custom WP plugin
- Is website for online game guides doable in WordPress? [closed]
- filter just a portion of plugin function
- How to fix template and image buffering issues on website [closed]
- Hide attributes based on previous selection
- search by meta field in the regular WordPress admin panel search