If search matches taxonomy

I only wanted to match tags in a single taxonomy, so I was able to simplify the code as follows. My taxonomy is ‘post_tag’ — just swap yours out as needed. $i = 0; $search_query = get_search_query(); $term = get_term_by( ‘name’, $search_query, ‘post_tag’ ); if( $term !== false ) { $i++; $single_result = $term; } … Read more

meta_key & meta_value not working with get_pages and custom taxonomy

Custom taxonomies are not meta values, but rather their own thing. I don’t think wp_list_pages() or get_pages() can query based on a taxonomy, so I’d recommend using WP_Query instead: <?php $relevant_pages_args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => 65, ‘tax_query’ => array( array( ‘taxonomy’ => ‘relevance’, ‘field’ => ‘slug’, ‘terms’ => ‘alumni’ … Read more

How to use wp_category_checklist()?

Here is the answer I ended up with: $select_cats = wp_dropdown_categories( array( ‘echo’ => 0 ) ); $select_cats = str_replace( “name=”cat” id=”, “name=”cat[]” multiple=”multiple” id=”, $select_cats ); echo $select_cats; It displays a list of my categories that can be multi-selected as per my question. It’s a hack of wp_dropdown_categories, but it works.

Have a Custom Post Type index page display taxonomy items instead of posts

If you’d like to list the individual courses, i.e. the taxonomy terms, you’d use neither WP_Query nor the WP standard Loop. Instead, make use of the get_terms function to retrieve the courses. It returns an array of term objects (if the taxonomy does exist and has terms matching the function arguments). Iterate over that and … Read more

Custom dashboard menu does not stay open for the custom Taxonomy within it

I solved this by adding following function, add_action(‘parent_file’, ‘keep_taxonomy_menu_open’); function keep_taxonomy_menu_open($parent_file) { global $current_screen; $taxonomy = $current_screen->taxonomy; if ($taxonomy == ‘directory_category’) $parent_file=”directory”; return $parent_file; } If you are adding more taxonomies, just change if condition in above code like following if ($taxonomy == ‘directory_category’ or $taxonomy==’tax2′ or $taxonomy==’tax3)

Taxonomy as checkboxes

You need to make sure you cast all the terms as integers. Passing in strings will compare the id’s to the slugs, and end up creating new terms with the ids as the name. Edit Specifically, alter these two lines as follows (note the intval): wp_set_object_terms( $post_id, intval( $term ), $field[‘id’] ); … wp_set_object_terms( $post_id, … Read more

Add current class to queried term on taxonomy term archive

Try this instead: $terms = get_terms(‘MYTAX’); $currentterm = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); foreach ($terms as $term) { $class = $currentterm->slug == $term->slug ? ‘live’ : ” ; echo ‘<li class=”‘. $class .'”><a href=”http://website.com/?MYTAX=’. $term->slug .'”>’ . $term->name . ‘</a></li>’; } Basically you just need to reset your $class variable back … Read more

Check which registered sidebar a widget is added to

There isn’t a standard way to do it AFAIK in the form() method; here’s a function to do it: function wp158055_get_sidebar_id( $widget ) { foreach ( wp_get_sidebars_widgets() as $sidebar_id => $widget_ids ) { if ( array_search( $widget->id, $widget_ids ) !== false ) return $sidebar_id; } return false; } And call with $this. Note from the … Read more

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