get_posts cannot grab from specific category

Edit In response to OP’s answer: So you use post_type and add cat at the end. Like [tribe_events][_cat]=[value] This is absolutely incorrect. WordPress does not automatically create custom taxonomies in this manner. From the OP’s comment: I’m using tribe Events calendar. Check it there. Here is the relevant PHP file from the The Events Calendar … Read more

Problem with get_posts, tax_query and counting the number of posts

Try this again removing operator and relation arguments as follows: here is a useful link http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/ $products = get_posts(array( ‘post_type’ => ‘products’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘collection’, ‘field’ => ‘slug’, ‘terms’ => array($current_collection) ), array( ‘taxonomy’ => ‘type’, ‘field’ => ‘slug’, ‘terms’ => array($current_type) ), array( ‘taxonomy’ … Read more

get_posts only children from certain parents

You have two options: Call get_posts multiple times: one for the parent pages using post__in => array(2,4), and two for the child pages of each parent with post_parent => 2 and post_parent => 4 and finally merge all the results into a single array. Write directly your SQL query and use $wpdb->get_results. See this article … Read more

get_posts inside cron

Whenever you do get_posts or WP_Query or anything like that, it’s important to remember that the code is actually getting all of the Posts at once, and loading them from the database into memory. If you run out of memory, then your process will simply die with an error. Attempting to get very large numbers … Read more

Query posts ordering by title, but ignore ” and special characters

Try this… $posts = get_posts( array( “orderby”=> “slug”, “order” => “ASC”, “post_type” => “my-custom-post-type”, “posts_per_page” => -1, “fields” => “ids”, “meta_query” => array( array( “key” => “ams_park_id”, “value” => get_the_ID(), ) ) ) ); Noticed I changed “orderby”=> “title”, to “orderby”=> “slug”. Typically the slug will be close to the title but all of the … Read more

Get the exact SQL query that get_posts() generated

The get_posts() function creates an instance of WP_Query inside the function and simply returns the array of results. This WP_Query instance doesn’t override the global $wp_query and is out of scope by the time you need it. In short, I don’t see a way how you can get the requested SQL via get_posts(). An alternative … Read more

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