you can check with the_posts
hook if your shortcode exists and only enqueue the style if so :
function check_for_shortcode($posts) {
if ( empty($posts) )
return $posts;
$found = false;
foreach ($posts as $post) {
if ( stripos($post->post_content, '[CHANGE_TO_YOUR_SHORT_CODE') )
$found = true;
break;
}
if ($found){
$url = get_bloginfo( 'template_directory' );
wp_enqueue_style( 'my_login_Stylesheet',$url.'/my_login_Stylesheet.css' );
}
return $posts;
}
add_action('the_posts', 'check_for_shortcode');
Related Posts:
- how to include other plugins css files in a shortcode?
- shortcode doesn’t work
- Plugin form unable to process
- Layout shop page: resize images and columns
- How extend shortcode default values for a plugin?
- How to generate CSS from a shortcode within a plugin
- Can someone please tell me what is wrong with my plugin?
- Redirect to another page using contact form 7? [closed]
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- Form Plugin for Api Requests which is used via Shortcode
- Echo out element to another page.
- General Term for this form Field
- Page takes on two different formats
- WP Plugin CSS not being applied to page
- Is there a function to search for a wildcard value when calling a shortcode?
- How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]
- Display file contents within Plugin
- tag breaks shortcode output (other solutions don’t work)
- Is there an earlier hook than login_head or login_enqueue_scripts?
- wp_create_nonce function doesn’t work inside a plugin?
- How to disable CSS rule in Twentythirteen style.css?
- Input with spaces in Shortcode attributes overwritten by defaults
- Theme’s default styles are overriding my plugin’s custom CSS
- Form isn’t inserting data into database with ajax plugin
- Remove ALL css for a specific plugin page
- How can I create a custom shortcode that will return a custom post type by ID?
- New User Form – Custom Menu Page
- Image upload and other options in the same plugin settings form?
- Plugin Handle URL With Custom Theme
- Allow users of my plugin to define their own shortcode rather than use mine?
- Globally register styles but enqueue them selectively
- CSS from textarea in options page to frontend what to do
- custom changes removed after plugin update
- Adding Shortcode to Text Widget
- W3 Total cache “empty all caches” and no stylesheets render [closed]
- How to put JQuery/Ajax inside shortcode?
- wordpress prevent multiple shortcodes
- Admin Panel pagination link styles
- How to style the RSS wordpress?
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- How Do I Figure Out What File(s) to Edit from Looking at the Source Code [closed]
- When using Simple Fields plugin, how do I pull the information out of the database to display on a page?
- Anonymous Postings
- Trouble with editing template for “List category posts” plugin
- Creating an online questionnaire form – by Importing the questions from a spreadsheet?
- WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
- Can I use custom CSS and js plugin to put JavaScript in to validate my forms
- Using a custom plugin to capture input data via Ajax and PHP
- WordPress function not being called from jQuery method
- WPBakery JS composer unused css [closed]
- How to tie dark mode with prefers-color-scheme webkit? [closed]
- AddToAny shortcode in the loop
- How to add an automatic refresh in WordPress for a Page/Post or an embedded OneDrive/Excel HTML Code?
- Trouble with plugin styles in admin area of WordPress
- Add a CSS class based on categroy id to archive pages
- Changing “elapsed time” to “time remaining” on MP3-jPlayer audio player with CSS or PHP changes
- How to fix wrong attribute error for Visual Composer Grid Builder?
- Making a Template for a CPT created by a plugin
- creating html reusable blocks via shortcodes
- Child Pages Short Code plug-in and hover capabilities?
- auto populate list of questions if user select a category xyz
- WordPress WPforms customization
- Removing included CSS file that doesn’t exist
- add_shortcode is not working in plugin where others are working
- Single API call exposed via shortcode with params
- How to hide CSS by default and show on button press
- (Sticky Row) How do i make a row sticky in wpbakery page builder?
- SEO Friendly URL on dynamic product page produced via shortcode
- How to create an input field, and base the output on spreadsheet data? [closed]
- Shortcode Plugin to dynamically build a shortcode via `do_shortcode` not working
- Contributive page where people logged in can write
- Contact Form 7 Get Image Function [closed]
- WordPress plugin output formatting
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Nested shortcode functions accessing variable
- Calling an attribute from a plugin shortcode
- Best place for short bio,image and button [closed]
- Submit page limited in time to upload image
- Adapt PHP form action for WordPress?
- how to access all user dashboard on fronted page [closed]
- Insert content of a post into another
- Is there any way to use google input tool or any other language keyboard with WordPress [closed]
- What would I need to write into a custom plugin in order to add a switch for a custom string of CSS to the edit page?
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Ajax fail and get 504 error
- Take input from form and pass it to function using a wp-plugin
- Ajax Search Lite: Customize Autoscroll
- Checkbox conflict in my custom plugin admin page
- Delete mobile menu button [closed]
- Widgets Scripts don’t load – but load when I reload the page
- Ability to automatically redirect a URL
- How to insert HTML/JavaScript form into WordPress page? [closed]
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- accessing wp.media api from a tinymce plugin
- Creating shortcodes in plugin
- Visual Composer shortcode for child theme dir
- get_post_title is not working on homepage
- Some code in shortcode function being ignored
- How do I make a child theme I made POST through a 3rd party plugin?