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:
- Help making my pagination plugin better
- Membership / subscription plugins – alternatives [closed]
- Having Multiple authors for the same WordPress Plugin
- How can a plugin run a script after being updated in MultiSite?
- File Storage Plugin (For Individual Users)?
- Manually Removing Plugins
- Pass A Value From Outside To A Plugin Variable
- Recommendationf for Quiz Plugin that saves results [closed]
- shortcode doesn’t work
- Add query string to plugin URL
- Will WordPress username displayed somewhere in the site?
- Events plugin for theater (event = performance of a production)
- Manually installed plugin doesn’t show up
- What are the benefit in adding hook in the init() hook?
- upgrade plugin in wordpress
- Are Drop-ins harmful for wordpress website?
- building plugin and it is displaying above plugins page
- WordPress URL redirect
- Is it dangerous to install unupdated plugins?
- Where to hook my plugin’s action
- load_theme_textdomain path
- Getting selected (highlighted) html from the Visual Editor on Edit Post page?
- How to query the custom fields by language?
- How to update plugins with database updates if I use svn
- Any recommendation on how to manage ads?
- List taxonomy terms for post as checkboxes
- Plugins not showing in Multisite dashboard
- How to create an archive page (with links) for a date range?
- How can I force users to a particular subdomain to log in for MU (Multisite)?
- Why WordPress plugin url ajax doesn’t work?
- Send reply with pre-prepared answers
- Why Is This Code Causing The Admin Bar to Disappear?
- WordPress stripping away backslashes from HTML
- Using Wishlist Member and I need to access a user’s status
- How to add wp visual editor in a custom widget?
- How to get DEFER or ASYNC attribute to appear when I add a stylesheet with wp_enqueue_style from a plugin? [duplicate]
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- allow photo/video in comments
- Excluding private/protected posts via IP
- Can’t get Gutenberg InspectorControls to work
- Socialite WP plugin, unable to obtain API keys from FB
- Choose which plugin to run based on user?
- Include a php file from another plugin
- order posts by `meta_key`, Does not display posts that does not have `meta_key`
- Too many login attempts
- How to change the wp_upload_dir() path in plugin
- Can the uniqueness of the plugin file/plugin slug and version number be trusted?
- How can I redirect some pages to new subdomain? [closed]
- wp-mail attachment is not sent for no reason?
- How to translate WP Blog (search, category etc.)?
- How can I concatenate variables to search results title? [closed]
- Sending customer an email with link to stripe to make payment
- I can’t change permalink in WordPress 4.5.3
- WordPress plugin: efficient way to store large data
- quicktag breaking FancyBox plugin on my blog’s front page
- Can’t create new CPTs when menu hidden
- Modify pages widget and make a plugin?
- Google Appointments in WordPress?
- Navbar affect loading all products
- How to make a Product page without ordering and database
- Codeless random token generation to pass into multiple tracking links in a single page load
- wp_options not returning value for logged out users?
- “SyntaxError: Unexpected end of JSON input” in WordPress checkout – how to debug?
- Custom WordPress feed on Apache server returning 304 response for if-modified-since
- RSS Feed on WordPress showing code (hypertext) in articles titles
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function
- How to create algorithm for ordering posts in WordPress?
- WordPress Gutenberg How to make TextControl Required?
- Display a number value from mysql query in WP
- the option to delete plugins is not there, I can’t download plugins either
- Front Page of Site Has Gone Replaced By Random Page
- How to deprecate a hook used in a plugin?
- How can I show login popup when user clicks on download button
- Flexslider empty slide
- Add subemenu option page
- get_permalink is causing a whitescreen
- Adding javascript to header of MetroMagazine theme
- How to Save settings of custom tab product page in admin side in a database?
- Issue: CSV file upload works only when “View page source” is done
- Unable to Retrieve Setting Value for my Plugin
- How to delete user meta by key
- galleria for WordPress not working properly on Mobile devices (responsive)?
- Get plugin versions in xml/json format
- Remove ‘Publish to Facebook’ checkbox for Facebook page publish plugin
- Make a wordpress site similar to Hot Or Not – Image rating system [closed]
- How to submit readme.txt file in wordpress directory
- wordpress shortcode A executing code from shortcode B
- _e in wordpress +
- How to create plugin list groups?
- how to restore wordpress backup(.rar) manually?
- WordPress Code Access to Restricted Content without Registration
- Any plugin/theme available which suits my requirement? [closed]
- How to pre-set WordPress settings for specific posts?
- Two sites one PC
- PHP if url extension action=discussion condition use [closed]
- Suitable hook when creating, updating and deleting posts programmatically
- how to make yoast seo read text from custom fields in custom post type
- How can I gather forums posted by visitors from different sites in one place? [duplicate]
- Does anyone recognize these table names?
- On WordPress.org Plugin repository, Last Updated Date doesn’t match with Plugin Version Update Date