Renaming Custom Taxonomy Values
You can register a custom taxonomy (Country) to your custom post type (Country Pages) and are connected through their ids. Updating the name of a taxonomy will affect all Country Pages.
You can register a custom taxonomy (Country) to your custom post type (Country Pages) and are connected through their ids. Updating the name of a taxonomy will affect all Country Pages.
The problem was ‘exclude_from_search’ => true in the register_post_type options. Given that setting ‘public’ => true defaults to exluding from search by default I assumed that this was the correct setting. However this is in the WordPress codex for register_post_type exclude_from_search: Note: If you want to show the posts’s list that are associated to taxonomy’s … Read more
As I stated in comments, you can either use usort() to sort the returned array of terms, or you can just use wp_get_post_terms() which is already sorted by default by name in ascending order $terms = wp_get_post_terms( get_the_ID(), ‘brand’ ); var_dump( $terms ); EDIT Here is an example with usort() and get_the_terms() $terms = get_the_terms( … Read more
You have lot of issues here; Never ever use query_posts, it breaks the main query and page functionalities. You are breaking and nullifying the main query even before query_posts can have a change to do it in this line $wp_query= null As this is a shortcode (taken from your comments) and with this line, ‘posts_per_page’ … Read more
This will get all posts with $old_tax, copy the terms from $old_tax to $new_tax, and then set the $new_tax terms for those posts. <?php function convert_tax($old_tax, $new_tax) { $pages = get_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => $old_tax, ‘operator’ => ‘EXISTS’ ) ) )); foreach($pages as $post) { $terms … Read more
Your tax query should be an array of arrays. Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays). This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy arrays. https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters ‘tax_query’ … Read more
Ok I got it! That’s the code for my search-results.php <?php include(‘../../../wp-load.php’); $term=$_GET[“term”]; $json=array(); $terms = get_terms( ‘produits’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ foreach ( $terms as $term ) { $json[]=array( ‘value’=> $term->name ); } } echo json_encode($json); ?> Thanks milo for your help ! I needed … Read more
Normally usage of get_term() or get_term_by() is pretty much clear cut. See the basic example below: // ID is needed $term_by_id = get_term( 12345, ‘destination’ ); echo $term_by_id->count; // Or if you e.g. want use the name (or slug or id or term_taxonomy_id) $term_by_name = get_term_by( ‘name’, ‘greece’, ‘destination’ ); echo $term_by_name->count; Note: I said … Read more
I assume location/state and location/state/city are template files. In those 2 template files you should copy the contents of header.php and edit there the title and the meta description. Also delete the request get_header().
Yes, wp_insert_term() only creates the term. To assign the term to a post use wp_set_object_terms() wp_set_object_terms( $object_id, $terms, $taxonomy, $append );