Taxonomy archives based on Custom Post Type

Here is a complete example made possible using add_rewrite_rule(). The basic setup for this example is documented first, then we’ll get to the real part of the solution using add_rewrite_rule(). Taxonomy and Post Type registration Register the genre taxonomy and the book, movie, and game post types (note that the singular version of each of … Read more

Why is my WP_Query not working when tax_query terms are an array?

When you’re doing a tax_query or meta_query in a WP_Query, you always have to use a nested array( array() ); just see the following example for an explanation and pay attention to the relation argument. $packages = new WP_Query( array( ‘post_type’ => ‘vamos-cpt-packages’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘vamos-holiday-types’, ‘field’ => … Read more

Get all terms inside a specific taxonomy in a multisite

No way to do that in a “word press” way… function multisite_profession_select(){ switch_to_blog(1); $taxonomies = array(‘rsitecat’); $check_later = array(); global $wp_taxonomies; foreach($taxonomies as $taxonomy){ if (isset($wp_taxonomies[$taxonomy])){ $check_later[$taxonomy] = false; } else { $wp_taxonomies[$taxonomy] = true; $check_later[$taxonomy] = true; } } $args = array(‘hide_empty’ => false); $terms = get_terms($taxonomies, $args ); echo ‘<pre>’; print_r($terms); echo ‘</pre>’; … Read more

Retrieve single term slug

Thank you guys for such quick response. Much appreciated! Here is code for “global” Tags page (displaying terms of default ‘post_tag’ taxonomy): <?php $term_slug = get_queried_object()->slug; if ( !$term_slug ) return; else $loop = new WP_Query( array( ‘post_type’ => ‘any’, ‘tag’ => $term_slug, ‘posts_per_page’ => 10 ) ); while ( $loop->have_posts() ) : $loop->the_post(); ?> … Read more

Child Terms not Displaying on the Taxonomy Term Admin Screen

I’ve encountered this kind of problem when i was building some front end post / term creation form. The number oh the ‘Right Now’ dashboard shows the right number of term, but the new term doesn’t shows up in the taxonomy admin screen. The solution: delete_option(‘taxonomy-name_children’); where ‘taxonomy-name’ is the name of the taxonomy. Hope … Read more

Custom hierarchal taxonomy loses interface hierarchy when selecting parent & children

This seems to be normal, it also happens for categories. The wp_terms_checklist(), which creates the checklist, has an argument checked_ontop, enabled by default. The metabox does not override this, so checked categories or custom terms always appear on top of the list. This does not affect their actual hierarchy, only how they are displayed there. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)