Swapping wp_dropdown_categories function with wp_category_checklist

As you are not working with the default categories but with another taxonomy instead you must not use wp_category_checklist(). Instead you should probably be using the more generic wp terms checklist(). The signature of this function also differs from the one of wp_dropdown_categories(). And the arguments array takes completely different options. You shlould start with … Read more

Use menu link or onClick to set a variable

By this you can pass the value using ajax, you have fetch value from $_POST in your php script jQuery(document).ready(function(){ jQuery(‘.dayLink a’).click(function(){ var li_id = jQuery(this).closest(‘.dayLink’).attr(‘id’); jQuery.ajax({ url: ‘url_to_php_script’, data: {dayValue: li_id,action:call_to_ajax}, method: ‘POST’, success: function(res){ console.log(res); } }) }); }); The closing brackets were out of order. <?php if(isset($_GET[‘li_id’])){ $test = $_GET[‘li_id’]; echo $test; … Read more

Create onClick Event to Re-load a Widget

I think you something like this. HTML Add this in widget <a href=”https://wordpress.stackexchange.com/questions/254474/javascript:void(0)” id=”add_my_fav”>Add To Favourite<span id=”favCount”></span></a> Ajax Add this in template <?php $nonce = wp_create_nonce(‘addToFav’); ?> <script> jQuery(document).read(function(){ jQuery.ajax({ url: ‘http://example.com/wp-admin/admin-ajax.php’, data: {action:”add_to_favourite”, secret:”<?php echo $nonce; ?>”}, method: ‘POST’, success: function(res){ jQuery(‘#favCount’).html(res); } }) }) </script> PHP Add this in functions.php function addToFavourite(){ if(isset($_POST[‘secret’]) … Read more

Plugin CSS not enqueing

If you want to add inline CSS, use wp_add_inline_style(). <?php /** * Plugin Name: WPSE 257470 * Description: WordPress StackExchange question 257470 * Plugin URI: https://wordpress.stackexchange.com/questions/257470/ * Author: Nathan Johnson * Licence: GPL2+ * Licence URI: https://www.gnu.org/licenses/gpl-2.0.en.html */ //* Don’t access this file directly defined( ‘ABSPATH’ ) or die(); if( ! class_exists( ‘wpse_257470’ ) ): … Read more

Input type search in Menu

This is fine, but you if you want things to look “cleaner” and be easier to modify you could instead create a new file menu-search.php and add your HTML there then tweak your function a bit (don’t forget to prefix your functions) function myprefix_add_search_box_to_menu($items, $args) { if ( $args->theme_location == ‘menu-1’ ) { ob_start(); get_template_part( … Read more