I cannot get tax_query in get_posts() to work with custom taxonomy

Does your custom post type have the setting publicly_queryable=true? Check the post type in the resulting query to see if it matches your post type. I’m guessing that your post type ‘distribution_centre’ is not being queried for one reason or another. add_filter( ‘posts_request’, ‘dump_request’ );//show the query function dump_request( $query ) { echo “<pre>”; var_dump( … Read more

Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?

After several hours of debugging I have found what caused the problem. Custom taxonomy ‘cadassist_category’ is used for 2 custom post types: product_document and cadassist_file. The posts for taxanomy with ID 653 were of cadassis_file type. And I tried to get posts of product_document type. That is why I got empty array. So if you … Read more

How to Get Position of a Post from a category and tag

Well, I fixed my own problem. If someone needs it in the future, you can use the code below: $query = new WP_Query( array( ‘cat’ => ’22’, ‘posts_per_page’ => -1, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘meta_key_here’, ‘order’ => ‘DESC’, ‘fields’ => ‘ids’ )); global $post; $i = array_search( $post->ID, $query->posts ) + 1; echo ‘<div … Read more

Category_in return empty

You can achieve that using the tax_query, see the example in the code below: $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘taxonomy’ => ‘the_taxonomy_slug’, //the slug of the taxonomy you want to get ‘field’ => ‘term_id’, ‘terms’ => $categories ) ); See reference in the Codex

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