List of child custom post types lists all custom post types
I think you’re confusing WP_Query with taxonomy arguments. WP_Query doesn’t have a child_of argument, use post_parent. and sort_column should be orderby.
I think you’re confusing WP_Query with taxonomy arguments. WP_Query doesn’t have a child_of argument, use post_parent. and sort_column should be orderby.
You can also use the following query for getting the results if you have author_id, post_status and cat_id with you. global $wpdb; $author_id = 1; $cat_id = 1; $post_status=”publish”; /* Post Titles */ $search_titles = $wpdb->get_col( “SELECT DISTINCT post_title FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) … Read more
You should use the WordPress AJAX-API for those purposes instead of custom scripts. Your problem is, that in your script all the WordPress API-Objects are not loaded. Here is an answer which describe the usage of the AJAX-API in a very similar case. There, a post is inserted to the database in the wpse_126886_ajax_handler() function. … Read more
I assume that by “direct children of category” you mean “posts directly assigned to the category” and not “posts assigned to child categories of the category specified”. The answer is in the Codex: Display posts that have this category (not children of that category), using category id: $query = new WP_Query( ‘category__in=4’ ); http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters Second, … Read more
This is more of a SQL question then a WordPress question. Here are some ideas: You’re most likely looking for this kind of structure: AND p.ID NOT IN (1433, 1344) You should consider using $wp->prepare() if your query depends on some user input. You might also want to replace CURDATE() with a PHP generated date … Read more
add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ ); function add_my_post_types_to_query( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( ‘post_type’, ‘any’ ); return $query; } refer to http://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
I just ran into this with WooCommerce. I ended up passing the IDs I needed to a variable for safe keeping, and then hooking a function with extremely low priority. That worked fine. I figure woocommerce or what of my cleint’s 8000000 plugins was overwriting post__in. add_filter(‘pre_get_posts’, ‘assign_ids’, 1000);
WordPress by default will only load 10 posts. That can be changed in the admin under Settings->Reading and then setting the amount beside “Blog pages show at most”. You can override that number in your custom queries a couple of ways but I would first recommend against the use of query_posts() ( take a read … Read more
$wpdb->query() returns number of rows affected by the query. It’s returning NULL indicates that there is an error in your query. The problem with your query is that you are updating $wpdb->posts table, but the condition depends on $wpdb->postmeta table. You have to join these tables for the query to work. Another problem is that … Read more
Use pre_get_posts instead.. function my_archive_query_override( $query ) { if ( $query->is_archive() && $query->is_main_query() ) { $query->set( ‘orderby’, ‘rand’ ); } } add_action( ‘pre_get_posts’, ‘my_archive_query_override’ ); For that user selectable part, you can use AJAX to accomplish that.