When using get_terms with hide_empty = true, terms that only contain scheduled posts are not returned. How to override this?
When using get_terms with hide_empty = true, terms that only contain scheduled posts are not returned. How to override this?
When using get_terms with hide_empty = true, terms that only contain scheduled posts are not returned. How to override this?
Started researching term arrays and came up with something that works, the solution for creating a conditional based on whether or not a term is in use by any post: <?php $categories = get_categories(‘taxonomy=listing-neighborhood&post_type=listings’); ?> <?php $term_name = wp_list_pluck( $categories, ‘name’ ); $this_name=”Open House”; if( in_array( $this_name, $term_name ) ){ echo ‘<option value=””>Select status or … Read more
OK, found it. it is possible to have the same slug for a page and a category name. The problem was that someone installed a “redirection” plugin that caused the problems. Lesson learned is to restrict the capabilities of people working on the website, so that they cannot install plugins..
Can try this: $terms = get_the_terms ($post->id, ‘skills’); if ( !is_wp_error($terms)) : ?> <?php $skills_links = wp_list_pluck($terms, ‘name’); $skills_yo = implode(“, “, $skills_links); ?> <span><?php echo $skills_yo; ?></span>
wp_get_object_terms() returns the terms associated with an object (eg a post or a page or custom post) as text (normally in an array). From the Codex page for wp_get_object_terms() $productcategories = wp_get_object_terms($post->ID, ‘productcategories’);
Here is another way to do something similar, with one SQL query: static public function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->prepare( “SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpdb->term_relationships AS r ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN $wpdb->posts AS p … Read more
Replace attribute terms with wp_update_term (woocommerce)
Display posts from Custom Post Type, group by term, arrange term groups and arrange items within groups by menu order
Get a custom post type’s taxonomy type term names displayed as checkboxes and filter
This is the pattern for a filter. Applying/using a filter on something: $filtered_version = apply_filters( ‘the name of the filter’, $the_thing_being_filtered ); This is how you use a filter to modify something: add_filter( ‘the name of the filter’, ‘name_of_a_function_that_will_modify_the_thing_being_filtered’ ); function name_of_a_function_that_will_modify_the_thing_being_filtered( $the_thing_being_filtered ) { // modify $the_thing_being_filtered here return $the_thing_being_filtered; } So in your … Read more