Get the posttype of a taxonomy/term

On StackOverflow user indextwo suggests to do the following: Use the get_taxonomy( $taxonomy-slug ) function which returns an object that contains all the associated post types. As suggested in the comments, we can then use get_post_type_object( $post-type-slug ) to get the object and Singular Label. $post_type_names = array(); // Array( ‘post-type-slug’ => ‘Post Type Label’ … Read more

Separate Posts and Custom Post Type in Custom Taxonomy archive template

Going from memory this should work for posts <?php $query1 = new WP_Query( array( “post_type” => “post”, “tag” => $term->slug) ); ?> The first query will only return posts that have been tagged [TEAMNAME] (as far as I can remember custom taxonomies can show up as tags on a post). This should work for teams … Read more

How do I provide a “show all posts” link in a paginated term archive?

This method will set it up so that if you add /all to the end of your taxonomy archives, it will show all posts. First, when registering the taxonomy, make sure you set the ep_mask to EP_CATEGORIES. This means we can add a custom endpoint to it. function wpse_277843_register_taxonomy() { register_taxonomy( ‘game_go_series’, ‘game_go’, array( ‘rewrite’ … Read more

Get Custom Field Values by Another Custom Field in WordPress

After struggling with this, I found a workaround that worked. Since every custom field has a connection with my custom post type, I was able to use wp_get_object_terms to get the terms for each custom taxonomy. Using the query to retrieve all posts: $args = array( ‘post_type’ => ‘houses’ ); $houses = new WP_Query($args); $posts … Read more

Woocommerce custom taxonomies page

After digging all over the place, it really was as simple as adding theme support. Go figure, just add the following: //Adding theme support function mytheme_add_woocommerce_support() { add_theme_support( ‘woocommerce’ ); add_theme_support( ‘wc-product-gallery-zoom’ ); //Only if want woocommerce built in add_theme_support( ‘wc-product-gallery-lightbox’ );//Only if want woocommerce built in add_theme_support( ‘wc-product-gallery-slider’ );//Only if want woocommerce built in … Read more

How can I display all post IDs from the taxonomy?

Just some code to get started. This will get you all the IDs for job_listings that are assigned to term 4 in your taxonomy. <?php $posts = get_posts( array( ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘post_type’ => ‘job_listing’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘agency’, ‘field’ => ‘term_id’, ‘terms’ => 4 ) ) ) ); … Read more