WordPress Widget Multiselect Issue

If someone is looking at this question, I managed to find a solution. 1. Switched to a checkbox instead of a multi-select and used “checked” instead of “selected”; 2. Used tax_query and some other query modifications. The code is not perfect but it works for now. Working Widget Code for Displaying the last 10 entries … Read more

WordPress category widget only show categories with children

I would suggest something like this: function exclude_widget_subcategories($args){ $all_categories = get_terms(‘category’, array(‘parent’ => 0, ‘fields’ => ‘ids’)); $exclude_categories = array(); foreach($all_categories as $category_id){ $children = get_term_children($category_id, ‘category’); if(count($children)!=0){ $exclude_categories[] = $category_id; } } $exclude = implode(“,”,$exclude_categories); // The IDs of the excluding categories $args[“exclude”] = $exclude; return $args; } add_filter(“widget_categories_args”,”exclude_widget_subcategories”); get_terms(‘category’, array(‘parent’ => 0, ‘fields’ … Read more

Display Custom Toxonomy In WordPress and theme Widgets category selection dropdown list

I took a look at the theme’s code. the function covernew_get_terms() function accepts a taxonomy argument, take a look at the source code: /** * Returns all categories. * * @since CoverNews 1.0.0 */ if (!function_exists(‘covernews_get_terms’)): function covernews_get_terms( $category_id = 0, $taxonomy=’category’, $default=”” ){ #… rest of the code } endif; By default the taxonomy … Read more