Maintaining Queries in URL
Maintaining Queries in URL
Maintaining Queries in URL
When you run a search (you call it a query) WordPress must use its DBMS (MariaDB / MySQL) to examine the entire text of every post, page, and user on your site. That takes time. There are some plugins out there to make search more efficient, but it is still work for your site to … Read more
Order posts by custom field DATE value
I would use the built in API like Rarst mentioned. You could do something like this: $just_seven = new WP_Query( array( ‘category__in’ => array( 7 ), ‘category__not_in’ => array( 10 ) ) ); You would then have those items in $just_seven->posts. However, if you MUST use a direct SQL statement, I’d suggest using INNER JOIN … Read more
The asker refused to post his solution as answer, so I took the liberty to get this question out of our growing Unanswered Questions list … <?php $logo = get_post_meta($post->ID, ‘_lm_comm_logo’, true); $map = get_post_meta($post->ID, ‘_lm_comm_map’, true); $args = array( ‘numberposts’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, … Read more
http://codex.wordpress.org/Class_Reference/wpdb query returns the number of affected rows. Instead use get_results, which returns all the rows specified by the query. You can use the second parameter to specify how these results will be returned, either as objects or as an array etc When dealing with sql, you should deal only with wpdb, there is very … Read more
Edit: I believe my comments below are still valid, but I suspect part of the problem is the ‘relation’ => ‘OR’, This should be ‘AND’ (it’s default value,so it can be removed) to ensure that it only returns posts which satisfy both conditions. Currently it will return events that start, or end, after yesterday. In … Read more
Gladly there’s a function that will output exactly that query string for you (still laughing about it 🙂 ). Here it is: get_posts_by_author_sql @queryposts.com, which looks in the core source like this. In detail it builds the WHERE part for you, that you can drop into your query. So just throw the user ID in … Read more
Your date format is wrong, MySQL date format is yyyy-mm-dd. Once you get that fixed, see WP_Query‘s meta_query, no need for raw SQL in this case.
your are comparing time against wrong time string: change: ‘meta-value’ => date(‘Y-m-d’, strtotime(‘-6 hours’)), //value of “order-date” to this ‘value’ => date(‘m-d-Y’, strtotime(‘-6 hours’)), //value of “order-date” because your time string is in m-d-Y format and you are check against Y-m-d which is wrong. NOTE if above trick doesn’t work then i suggest you to … Read more