wp_set_object_terms() Fails to Set Terms
I don’t have a solution, but there’s a ticket #20541 on Make WordPress Core. Apparently a call to switch_to_blog() would not repopulate $wp_taxomies, which these taxonomies rely on.
I don’t have a solution, but there’s a ticket #20541 on Make WordPress Core. Apparently a call to switch_to_blog() would not repopulate $wp_taxomies, which these taxonomies rely on.
The issue is with the taxonomy cache. You have to clear it after you insert the terms in order to see them. I had the same issue, which someone answered for me here: delete_option(“classified-category_children”); Insert that after the term inserts and you should be good.
Working off of Pieter Goosen’s answer to this question, the way around this is to create a list of all the categories except the one you want to exclude, then search for posts that include them. That way, if a post has the excluded category but also other categories, it’ll be included. So, in my … Read more
See the follow-up post: http://scribu.net/wordpress/sortable-taxonomy-columns.html
The get_terms() (see docs) function accepts the same args as WP_Term_Query(see docs) You have to get those terms Ids first and then pass it to the exclude arg: // default to not exclude terms $ids_to_exclude = array(); $get_terms_to_exclude = get_terms( array( ‘fields’ => ‘ids’, ‘slug’ => array( ‘graduate’, ‘job-market-candidate’, ‘graduate-student’, ‘research’ ), ‘taxonomy’ => ‘role’, … Read more
You will need to grab the queried object for the page and fill in your taxonomy information dynamically. if (is_tax() || is_category() || is_tag() ){ $qobj = get_queried_object(); // var_dump($qobj); // debugging only // concatenate the query $args = array( ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’, ‘tax_query’ => array( array( ‘taxonomy’ => $qobj->taxonomy, ‘field’ => … Read more
Use get_term() to get the name, slug, or description: $term = get_term( 1, ‘taxonomy_slug’ ); // Name echo $term->name; // Link echo get_term_link(1, ‘taxonomy_slug’); // OR echo get_term_link( $term );
To get a list of your custom taxonomies, you can use the get_terms() function to create a loop: // Get the taxonomy’s terms $terms = get_terms( array( ‘taxonomy’ => ‘your-taxonomy’, ‘hide_empty’ => false, ) ); // Check if any term exists if ( ! empty( $terms ) && is_array( $terms ) ) { // Run … Read more
You’re almost there mate. Try this though. <?php add_action(‘pre_get_posts’, ‘filter_press_tax’); function filter_press_tax( $query ){ if( $query->is_tax(‘press’) && $query->has_term(‘press’)): $query->set(‘posts_per_page’, 5); return; endif; } ?> You can use any conditional tag or any argument that can be passed to WP_Query to test your condition or set a new value via pre_get_posts. Also try $query->get(‘taxonomy’) / $query->get(‘term’). … Read more
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>