Loading scripts only if a particular shortcode or widget is present

You can use the function is_active_widget . E.g.: function check_widget() { if( is_active_widget( ”, ”, ‘search’ ) ) { // check if search widget is used wp_enqueue_script(‘my-script’); } } add_action( ‘init’, ‘check_widget’ ); To load the script in the page where the widget is loaded only, you will have to add the is_active_widget() code, in … Read more

Widget text color change

This CSS will make your grey text in some else you want: .widget_posts_wrap .latest-posts .col-md-12 a span {color:#your-hex-code !Important;} This is for subtitles in this widget where you have latest post. And this is for titles: .widget_posts_wrap .latest-posts .col-md-12 h3 a {color: #your-hex-code !important;} Also just note to change #your-hex-code part with actual hex code. … Read more

My plugin works in home page, but doesn’t work in post page

I think ajax request should point to the actual WordPress ajax handler. You can pass the variable by localising the script: $js_object = [ ‘ajaxUrl’ => admin_url(‘admin-ajax.php’) ]; wp_register_script(‘my-script’, ‘http://url’); wp_localize_script(‘my-script’, ‘pluginObject’, $js_object); wp_enqueue_script(‘my-script’); Register the ajax request into ajax hook: function widget_ajax_request() { // your stuff } add_action(‘wp_ajax_my_action’, ‘widget_ajax_request’); add_action(‘wp_ajax_nopriv_my_action’, ‘widget_ajax_request’); And your JS … Read more

New Custom Widget Call a Different Widget Function

As I’m not able to comment yet, I can only answer. But I’ve got questions. How does the widget get used? Where is it called? is the ORIGINAL script you posted above in a file like /theme/twitter-widget.php? Or is it in your functions.php script for the theme? Something wasn’t configured to run YOUR widget, and … Read more

conditional widget title

Not a lot to go on here! I’d suggest registering 2 different sidebars – one for the category 3 posts and one for the rest. Then you can add you widgets and modify them as required.

Using the_widget Multiple Times

I’ve written custom functions for queries. <?php /** * Column Content (min:2 – max:3 column) * * @since 1.0.0 * @return void */ if ( ! defined( ‘ABSPATH’ ) ) { exit; } add_action( ‘widgets_init’, function(){ register_widget( ‘Hw_Column_Widget’ ); }); class Hw_Column_Widget extends WP_Widget { /** * Sets up the widgets name etc */ public … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)