Get queried object for custom post type count

function wpse340250_term_count( WP_Term $term, $post_type) { $q_args = [ ‘post_type’ => $post_type, ‘nopaging’ => true, // no limit, pagination ‘fields’ => ‘ids’, // only return post id’s instead of full WP_Post objects will speed up ‘tax_query’ => array( array( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘term_id’, ‘terms’ => $term->term_id, ), ), ]; $term_count = get_posts($q_args); return … Read more

Search for single post by 2 tags

Using the tax_query param in your args (and replacing the dot with a comma) should get you what you’re looking for: $args = array( ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => ‘fetch’, ), array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => ‘agirt’, ) ) );

WP_Query not using custom taxonomy categories on custom post type

WP_Query only returns WP_Post objects for the results. To get the taxonomy terms for each post you need to use get_the_terms( $post, ‘recipe_categories’ ); for each post. This is because WP_Post represents each row of wp_posts, which does not include taxonomy information. The links between posts and terms is in the wp_term_relationships table.

Display Custom Field or Custom Taxonomy in front page /post/product

It depends on the theme you’re using if it has the functionality to show the information. Usually, if you had a custom attribute using default WP, it will show those but for advance custom fields you might need to add the code into your theme. For example, the following code will help you to display … Read more

Custom Taxonomies Archive Page 404

I solved it with this workaround. I created a new page (“Movies” with the URL domain.cc/movies) and added this via shortcode: <?php $taxonomy = ‘artists’; $tax_terms = get_terms( $taxonomy, array( ‘post_type’ => ‘artwork’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ ) ); ?> <?php foreach ($tax_terms as $tax_term) { ?><div class=”artistslist”> <a href=”https://wordpress.stackexchange.com/<?php echo $taxonomy;?>/<?php echo … Read more

Custom post type query with taxonomy

Answering your second question – yes, it is possible, you can use tax_query for this, for example, this query will get all posts that has any term of ‘flowers’ taxonomy AND ‘colors’ taxonomy: $query = new WP_Query( array( ‘post_type’ => ‘custom-post’, ‘posts_per_page’ => 5, ‘order’ => ‘DESC’, ‘tax_query’ => array( ‘relation’ => ‘AND’, // it … Read more

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