Tagged Questions
1
vote
1answer
51 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 ...
1
vote
1answer
66 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:
...
2
votes
0answers
43 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
23 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 ...
0
votes
1answer
232 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
180 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
109 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
119 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
90 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
136 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
107 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));
...
0
votes
1answer
418 views
Custom query with filters returns wrong number of found_posts [closed]
I have a custom query with a couple of filters, defined in functions.php:
function myJoin($join) {
global $wp_query, $wpdb;
$join = "
LEFT JOIN $wpdb->postmeta AS i ON (
...
1
vote
2answers
245 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
328 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
1k 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
573 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
837 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
305 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 ...