Display custom posts for each category from its custom taxonomy

For those who wanted to know: <?php $cat_args = array( ‘taxonomy’ => ‘service_sections’, ‘orderby’ => ‘slug’, ‘order’ => ‘ASC’ ); $cats = get_categories($cat_args); // passing in above parameters foreach ($cats as $cat) : // loop through each cat $cpt_query_args = new WP_Query( array( ‘post_type’ => ‘services’, ‘service_sections’ => $cat->name ) ); if ($cpt_query_args->have_posts()) : ?> … Read more

Get custom taxonomy name (not the term) in custom post

I have found an hopefully elegant solution $taxonomy_names = get_object_taxonomies( $post, ‘objects’ ); foreach ($taxonomy_names as $tax) { if ($tax->query_var != ‘tag’) { // needed because $taxonomy names containes more than one query_var $current_tax_name_slug = $tax->query_var; } } This one works for me

Different structure/content for posts from a custom post type

WordPress allows to do this rather neatly for pages, supporting page-$slug.php and page-$id.php templates in hierarchy. Unfortunately it doesn’t apply to posts and Custom Post Types. So your options are either handling this inside single-services.php (in one file, or by further including other template files) or adjusting hierarchy to use custom templates for your posts … Read more

Add file attachments/meta to a custom Taxonomy

this tutorial will definitly solve your problem http://en.bainternet.info/wordpress-taxonomies-extra-fields-the-easy-way/ Yes i have used it to add feature images to the custom taxonomy terms.It depends how you registering the custom post .If you have registered the custom post as plugin from plugin directory , then you need to paste the downloaded folder i.e Tax-meta-class in directory of … Read more

Using custom taxonomy when registering a new custom post type

What you have should work in principle. Note that taxonomies argument needs existing taxonomy, that is one that is already registered at the time you are registering CPT. If the timing is problematic to get right during registration, you could also use register_taxonomy_for_object_type() to create association between the two separately from registration process.

Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]

If you’r using ACF plugin you should look the documentation first, here’s relevant ACF saves taxonomies terms meta to options table, and they can be accesed using get_field( “{$field_key}”, “{$term->taxonomy}_{$term->term_id}” ); So in you’r example it would be: $image = get_field( ‘featured_image’, ‘product-category_’ . $product_category[0]->term_id );