Having trouble using this post category query on multiple pages?
cat requires an ID, if you’re using the slug, set category_name instead. see WP_Query Category Parameters.
cat requires an ID, if you’re using the slug, set category_name instead. see WP_Query Category Parameters.
Why don’t you just use a custom hierarchical taxonomy where countries are children of parent region terms? Seems more suitable and natural to me.
Try following codes: $country_search_array = array(); while($row = mysql_fetch_array($regionresult)){ $country_search_array[] = $row[‘country’]; // Your country field name } $country_search = “‘”.implode(“‘,”, $country_search_array).”‘”; $args = array( ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘Country’, ‘value’ => $country_search, ‘compare’ => ‘IN’ ) ) ); $query = new WP_Query( $args );
Thanks for all of the help! It tured out to be a combination of issues: Instead of imploding the $country_search_array, it needs to be added as is to the query. Since it’s an array, we can’t use the ‘=’ for the compare value. It needs to be ‘IN’ I couldn’t have figured it out without … Read more
You can try adding a query var using the ‘query_vars’ filter like so: add_filter(‘query_vars’, ‘my_plugin_query_vars’); function my_plugin_query_vars($vars) { $vars[] = ‘login’; return $vars; } That may populate $wp_query->query_vars, if not I have successfully used the get_query_var function in one of my projects, try something like: function my_plugin_display() { if(get_query_var(‘login’)) { include( ABSPATH . ‘/wp-login.php’ ); … Read more
Looks like I was missing ‘paged’ => get_query_var(‘paged’) in the initial query.
The issue ended up being the page in which I was accessing the shortcode on was using the same slug – which WP was freaking out about. While I’ll need to investigate why it would happen, was easy enough to fix.
Probably some code on your site caches the result of an expensive operation. When the page is cached by W3TC, if on the very same page generation, cache was being regenerated, you will see the actual queries that operation requires. After that, queries are like the usual page load ones. Don’t worry about it until … Read more
Try this one you need to add ‘paged’ => get_query_var(‘page’) so your code in $my_query should be like this $my_query = new WP_Query(array( ‘post_type’=>’post’, ‘posts_per_page’=>’1’, ‘paged’ => get_query_var(‘paged’) )); You just need to pass along the ‘paged’ query var from the main query: You can see also Codex page on query_posts()
Did you try this? $paged1 = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1;