WP Query multiple select form – meta_query help
WP Query multiple select form – meta_query help
WP Query multiple select form – meta_query help
Your description of the problem is not very clear, and your inconsistent code formatting makes that hard to read (plus I am pretty sure some code is missing), but if the problem is running the query multiple times you can solve that with a static variable. function get_gametitle_info() { static $game_info_query = false; if (false … Read more
You could do (untested): if( get_post_type($post->post_parent) == ‘apples’ ){ get_template_part(‘single-apple-child’) } else { /* the rest of your current single page */ } Though there may be a better way!
After some Google searches, I found all I needed to do was set the custom_post_type registration to include hierarchical => true and this solved my problem.
orderby in WP_query doesn’t works
If you need to return one value then use get_var instead of get_row. get_var will return a string. get_row will return an array or object. $spr_liczbe_wodo = $wpdb->get_var (“select liczba_wodo from wp_ow_adres where adres=”Street 12/6″”); var_dump($spr_liczbe_wodo); The problem with your code, by the way, is that $spr_liczbe_wodo is an object, but when you loop over … Read more
When query iterates it holds the number of current post (zero-based) in current_post property: echo $wp_query->current_post % 2 ? ‘cat1’ : ‘catA’;
The problem is that if you pass multiple category to a query, then you’ll retrieve 4 posts ordered by date, but if you last 4 posts are all in one category, you’ll get all 4 posts from same category. You have 2 choices: run 4 different queries, one per category, and retrieve one post per … Read more
The post_type isn’t really a meta query – therefore, both of these post_types would at least 1 category added/queried in order to get the filter invoked – using plain SQL is still a last resort. add_filter( ‘posts_groupby’, ‘my_posts_groupby’ ); function my_posts_groupby($groupby) { global $wpdb; $groupby = “{$wpdb->posts}.post_date”; return $groupby; } According to your example (I’d … Read more
/doctors/ is a post type archive, so we can check if that query is being run in the pre_get_posts action via the conditional tag is_post_type_archive( ‘doctors’ ) and modify those queries accordingly. WordPress passes the query object to the function by reference ( $query in this example ), so we can modify the query vars … Read more