New answers tagged

0

dashboard widgets api to create the widget "wrapper" wp count posts to count number of items in a post type wp count terms to count items in a taxonomy (will need to use get_terms to get every term then use wp_count_terms in the loop) That should get you close to what you want :)


0

I'd set up... Teams and Tournaments as taxonomies Players and Managers as post types. If you link the taxonomies to both post types you will be able to link both Players and Managers to the same Team or Tournament. CPT UI is a pretty good plugin to help create and manage custom post types.


4

There are e.g. the following dynamic sanitize_term_fields() filters: edit_term_{$field} filter for the edit context pre_term_{$field} filter for the the db context term_{$field}_rss filter for the the rss context term_{$field} filter (default) and also the taxonomy-specific ones: edit_{$taxonomy}_{$field} filter for the edit context pre_{$taxonomy}_{$...


1

As of WP 3.7 (https://core.trac.wordpress.org/ticket/14206) you can add this argument to register_taxonomy: 'meta_box_cb' => 'post_categories_meta_box' to get the built-in checkbox category style metabox without having to make your taxonomy hierarchical. Also you could instead provide your own callback function to create your own metabox (i.e. with a ...


0

Without seeing the code, it's a bit hard... But if you're trying to query for a certain taxonomy when 'post_type' => 'page', make sure you Add a registered Taxonomy to a registered Post Type. (See Codex) In this case, you would add it to 'post_type' => 'page' since "Pages" do not support any taxonomies by default. Again, you may have done this ...


0

If you want the terms ordered by slug rather than name then use this... <?php if(has_term('', 'CUSTOM-TAX')) {?> <?php $custom_terms = get_the_terms( get_the_ID(), 'CUSTOM-TAX' ); // Make sure we have terms and also check for WP_Error object if ( $product_terms && !is_wp_error( $product_terms ) ) { @usort( $...


2

The dynamic filter "term_{$field}" is probably what you're looking for, where the field is "name." One approach is to have an array of names and their pseudonyms, then do a check-and-return on them so they'll display the replacement. add_filter( 'term_name', function( $value ) { $terms = [ 'old' => 'new', ]; // basic example check, ...


0

I've actually had a brain fart, and just figured it out.. Since I don't have any single posts, there was no reason to even be rewriting the CPT itself. I simply removed the rewrite line from the CPT and everything is working perfectly.


0

I've finally solved this problem. I'm copying the code because it may help someone :) I've found the solution by populating an arrray and checking if a brand is or is not there, so I only get each brand one time. <?php //Query to match department $args = array( 'tax_query' => array( array( 'taxonomy' => '...


0

as long as the slugs from your articles taxonomy map exactly to the slugs in your default category you should be able to do something like this for each article: $article_cats = wp_get_object_terms( $article_id, 'article-category' ); $new_cats = array(); foreach( $article_cats AS $t ) { $new_cats[] = $t->slug; }...


0

Even if default posts are stored in same table but they have different behavior and different characteristics. CPT has post type archive but default post type archived is called as blog and the taxonomy filter is called as tag/category archive. You can access the category/tag archive using For categories: /?cat={category_id} //e.g. ?/cat=5 For tags: /...


0

Try this code after the $bio = wp_insert_post( $my_bio_post ); line: $terms = isset($_POST['my_pet']) ? array_filter($_POST['my_pet']) : 0; if ($terms && $bio) wp_set_object_terms($bio, $terms, 'Cats'); See wp_set_object_terms() for more info and make sure the Cats taxonomy and the terms in your checkboxes is already available.



Top 50 recent answers are included