1
vote
1answer
19 views

How to count post meta key values for all posts in database

In my post meta data I have the following 'key' for every post: "image_details" a typical value of which is an array such as: ...
0
votes
1answer
83 views

meta_query on a date range using an array of values

How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... // the ...
0
votes
1answer
14 views

meta_query dates from an array

I have the below query which isn't returning anything. The query is meant to look for the date (2014-03-01) that is in the array, which it is. Any ideas? Or would I need to use a custom SQL query? ...
0
votes
2answers
211 views

Query multiple meta key values for template

I am using this template: http://demo.undsgn.com/studiofolio/front-page/ I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied ...
0
votes
1answer
1k views

Order by DESC, ASC in custom WP_Query

I need to do multi-level ordering in a query. The issue is with ordering one value DESC and the other ASC as in SQL. The following SQL seems to give me what I want when I run it in terminal: SELECT ...
0
votes
1answer
71 views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
1
vote
1answer
138 views

Mysql query and order meta value

I made a mysql query to WordPress like this: $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND ...
3
votes
1answer
332 views

How to prevent execution of default query, while preserving ability to use WP_Query in template?

PROBLEM: I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries: ...
3
votes
2answers
105 views

Query meta field using between

I'm trying to Query some lattitude and logitude and then I get some long numbers and apperently the Query dont like that. Let says I have these in the database Meta-key: lat Meta-value: 54.3415000 ...
0
votes
1answer
29 views

Assign a tag to custom post type using a query

I have a custom post type courses with a custom field level. I want to run a query (mysql or WP query) that runs through every course (post) and if the level is greater than 3, append a tag called ...
1
vote
1answer
544 views

Help with WP_Query - Too many mySQL queries

I need some kind of help with wp_query. Am I doing something wrong? I am getting a lot of mySQL queries, while building a new theme. My WP_Query is: <?php $args = array( 'post_type' => ...
4
votes
1answer
261 views

find a random blogid across my multisite network that has at least one post published

I need to find a random blog across my multisite network that has at least one post published of a certain post_type, and return its blogid as a variable so I can use it in a switch_to_blog() call. I ...
1
vote
0answers
148 views

Query most popular terms by taxonomy over 2 week period

I have written SQL for a query that pulls the most used taxonomy terms for selected taxonomies that are published, do not have a parent post are not in a comma separated list over the past two weeks ...
1
vote
0answers
180 views

List authors with the last post title and order by last post date

I want to list authors with last post data and order them by last post date. Now i have this codes but i don`t know how to edit them. // Selects from tables wp_users and wp_posts, selecting published ...
0
votes
1answer
99 views

Different sql queries count indicator on the main page

I use w3_total_cache plugin. But i can`t understand what is going on sometimes. I have enabled database caching and debug info at the bottom. Sometimes on the main page 90-96 db queries, sometimes ...
0
votes
2answers
218 views

Parsing External Table Arguments

I have a client project that has posts assigned to their country of origin. The client wants to be able to search the posts by continent and or region. I have a separate table that assigns each ...
0
votes
1answer
160 views

get_var is neither a string, integer, or array …?

$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND company = %s", $product, $company)); ...
1
vote
2answers
374 views

Mysql query LIKE not working

I'm using this code. $blog_list = $wpdb->get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb->blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' ...
0
votes
1answer
581 views

Difference between 'LIKE' and 'IN' in meta queries

You can use a variety of different comparison operators in meta queries, among which are 'LIKE', 'NOT LIKE', 'IN', and 'NOT IN'. What is the difference in use between LIKE and IN? Here's the ...
4
votes
2answers
2k views

Get posts by menu ID

I'm a little stuck here. I have a menu in Wordpress with some posts in it. What I would like is to retrieve all the posts as objects. I think I'm pretty close, but the SQL query doesn't seem to work ...
0
votes
3answers
744 views

How to find if a post with custom_field == X exists?

I need to find if a post with a custom field X equal to Y exists in a wordpress installation. Should I do it with a simple sql query or is there something build in that can help me achieve it?
0
votes
2answers
944 views

Custom query_posts() parameter

I'm adding voting features to a theme. Visitors can vote posts Up or Down. I created a table for storing number of votes for each post and that works fine. Now I'm trying to sort posts by their votes. ...
1
vote
1answer
347 views

if statement on database query

Part of a voting script I'm working on: I'm checking a custom table in my WP database to see if a user already voted for a post by checking the IP address and the post id. If the user's IP already ...