new WP_Query() – what is the earliest valid hook?
As @Milo pointed out in the comments above, custom post types and taxonomies are registered on init, so this would seem to be the earliest hook available that is guaranteed to work for all content.
As @Milo pointed out in the comments above, custom post types and taxonomies are registered on init, so this would seem to be the earliest hook available that is guaranteed to work for all content.
I just got the same problem and the problem was exclude_from_search post_type option. It seems that WordPress got a bug (I’m just going to report it), that when you got exclude_from_search false, the posts do not show on tax pages
It sounds like you really need to be using posts for your content rather than pages since you want to organize your content into categories. You can use a page to display a custom page template (the Template Name: comment as shown below defines a new page template; that template will then be available as … Read more
Custom query incorrectly returning everything [closed]
Display one post from each term in a custom taxonomy [closed]
First of all, never use query_posts, ever. My emphasis. It is outright not meant to be used at all, and should be removed in future wordpress versions. Overall performance wise I would say it is even worse than a custom query. You should really be using WP_Query for the task at hand Note: This function … Read more
Not tested but you can try this: $args = array( ‘posts_per_page’ => 4, ‘post_type’ => ‘post’, ‘meta_key’ => ‘meta-select’, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value_num’, ‘meta_query’ => array( array( ‘key’ => ‘meta-select’, ‘value’ => array( 2, 3, 4, 5 ), ‘compare’ => ‘IN’, ), ), ); Ordering is done by value of meta field meta-select … Read more
The use of SQL_CALC_FOUND_ROWS is not really a problem, although it incurs an overhead. What happens is, WordPress uses SQL_CALC_FOUND_ROWS in order to determine the total posts that would have been returned, if no LIMIT clause was provided. This is necessary in order to calculate and provide you with correct pagination links. Disabling it unconditionally … Read more
Using WP_Query, you can order the results by meta_value_num: $args = array ( ‘post_type’ => ‘clinica’, ‘meta_key’ => ‘distance_field_name’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ );
Here’s one way by using wpdb::get_col() and fetch the id column: $pids = $wpdb->get_col( “SELECT id FROM my_table” ); We could then clean it by integer convert each id with: $pids = wp_parse_id_list( $pids ); Just note the different max value for intval(), depending on 32 or 64 bits systems.