Dequeue, Unregister, Remove Action – Not Working on Plugin

Going off of the plugins source code I simply copied then changed the add_action(); to remove_action(); in my child-themes function.php add_action(‘wp_print_styles’, ‘add_advanced_recent_posts_widget_stylesheet’); Replace add with remove. remove_action(‘wp_print_styles’,’add_advanced_recent_posts_widget_stylesheet’); So simple. Now I know.

I can’t add CSS with functions.php

Before adding any file you must seperate your header.php file & add wp_head() function in header.php file // Load the theme stylesheets function theme_styles() { // Example of loading a custom css file for homepage just on the homepage wp_register_style( ‘custom’, get_template_directory_uri() . ‘/css/custom.css’ ); if(is_page(‘home’)) { wp_enqueue_style(‘custom’); } // Example of loading a main … Read more

Apply function only if end of url has /amp/ [closed]

In your example, $_SERVER[‘REQUEST_URI’] would return /category/post-slug/amp/ which is not the same as get_permalink($post->ID) which would return https://example.com/category/post-slug/ There are lots of ways to go about this, but one easy one that comes to mind is… if ( strpos($_SERVER[‘REQUEST_URI’], ‘/amp/’ ) !== false ) { The strpos() PHP function finds the position of 2nd string … Read more

How to make my shortcode load scripts and styles, from within the plugin?

plugins_url expects the second parameter to be the main plugin file, which is why __FILE__ is used in examples, it’s assuming the code is in that file, but yours is not. To fix this, you will need to retrieve __FILE__ in your main plugin file, store it, and pass it to your shortcode objects for … Read more

Style file inclusion

You need to hook it to an action. Add the below code to the theme’s functions.php file. It should work. add_action( ‘wp_enqueue_scripts’, ‘theme_flexslider_css’ ); function theme_flexslider_css() { wp_register_style( ‘flexslider’, get_template_directory_uri() . ‘/css/flexslider.css’ ); if( is_page( ‘home’ ) ) { wp_enqueue_style( ‘flexslider’ ); } }

How to dequeue css files?

Use the correct action hook Notice the action hook being used: add_action( ‘wp_enqueue_scripts’, ‘add_our_scripts’,0); And the action hook you’re defining/using: add_action( ‘test_remove_scripts’, ‘remove_radium_scripts’, 999 ); You need to hook into the same action: add_action( ‘wp_enqueue_scripts’, ‘remove_radium_scripts’, 999 ); Use the correct priority Notice the priority being used: add_action( ‘wp_enqueue_scripts’, ‘add_our_scripts’,0); And the priority you’re using: … Read more