Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress enqueue if shortcode

//Enqueue only if shortcode Exists on wp_content
add_action('wp_enqueue_scripts', 'myplugin_stylesheet');
function myplugin_stylesheet() {
  global $post;
  if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'myplugin-shortcode-name') ) {
    wp_enqueue_style( 'myplugin-style', plugins_url('myplugin-style.css', __FILE__));   
  }
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel scheduler on shared hosting 
Php :: laravel 8 with jetstream 
Php :: how create page 419 in laravel 
Php :: extend woocommerce user fields edit-account 
Php :: php trim 
Php :: json_encode php 
Php :: two condition in one laravel query 
Php :: switch between php version ubuntu 
Php :: Write a Multiplication program of two numbers in php using operator 
Php :: insert into database with seeder 
Php :: insert into laravel 8 
Php :: php display json in browser 
Php :: php flip array 
Php :: php iterate through a loop 
Php :: random string number generator in php codeigniter 
Php :: constants in php 
Php :: php preg replace 
Php :: php include multiple files at once 
Php :: asin() php 
Php :: remove last 3 character from string php 
Php :: static class methods php 
Php :: CHECKING IF FILE IS EMPTY IN PHP 
Php :: which programming languae does php resemble to? 
Php :: php namespace class 
Php :: return back laravel controller 
Php :: laravel vreeze 
Php :: laravel not run test 
Php :: laravel datatables 
Php :: find diiference in minutes un laravel 
Php :: magento 2 colllection set select 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =