Custom Taxonomy Query

NOTE: This answer is supposed to be in addition to the answer here The function used returns an array of all the items, so the best way to display them is to use a foreach loop. As a usage example global $wpdb; $result = $wpdb->get_col(….); //copy the line from the aforementioned answer if($result) { echo … Read more

List related terms + taxonomies

You probaby want get_terms(). WordPress keeps a count of the number of posts that use a taxonomy and you can filter your query using it: // get all the terms in the ‘category’ taxonomy $terms = get_terms(‘knife’); // list all the terms that have at least one post foreach ($terms as $term) { echo “{$term->name} … Read more

Search by tag name and category

use this function put in function.php file for cat=22 filter change your cat id for you mind function my_search_form( $form ) { $form = ‘<form role=”search” method=”get” id=”searchform” action=”‘ . home_url( “https://wordpress.stackexchange.com/” ) . ‘” > <div><label class=”screen-reader-text” for=”s”>’ . __(‘Search for:’) . ‘</label> <input type=”text” value=”‘ . get_search_query() . ‘” name=”s” id=”s” /> <input … Read more

How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?

You should be using the register_deactivation_hook and/or register_uninstall_hooks. That may be why some functions don’t work. I’d have to do some testing to be sure, but loading your method directly like WP_Plugin_Janitor::cleanup( $opt, $cpt, $tax ); seems like a pretty good way to skip over some of the WordPress load sequence or to run things … Read more

How to display products name in a non-alphabetical order, in a custom field (taxonomy)?

[SOLVED] This do the Job: function set_the_terms_in_order ( $terms, $id, $taxonomy ) { $terms = wp_cache_get( $id, “{$taxonomy}_relationships_sorted” ); if ( false === $terms ) { $terms = wp_get_object_terms( $id, $taxonomy, array( ‘orderby’ => ‘term_order’ ) ); wp_cache_add($id, $terms, $taxonomy . ‘_relationships_sorted’); } return $terms; } add_filter( ‘get_the_terms’, ‘set_the_terms_in_order’ , 10, 4 ); function do_the_terms_in_order … Read more