Tagged Questions
0
votes
1answer
17 views
Adding an orderby filter, casting postmeta with multiple keys
I am using this filter to sort my query by a date field stored as text (legacy data)
add_filter( 'posts_orderby', 'my_posts_orderby_date', 10, 2 );
function my_posts_orderby_date( $orderby, $query ) ...
0
votes
0answers
39 views
Retrieve post data via WPDB class
I'm trying to figure out doing a custom query using the $wpdb Object.
I have custom type posts, event_posts, that have meta data, images, as well as event dates which are input in the post with the ...
0
votes
1answer
70 views
Select from wp_post and multiple meta_value from wp_postmeta
My lack of SQL skills has stopped me in my tracks here.
I'm trying to select post_id, post_title and two postmeta values - the first has the meta_key of 'search_country' and the second a meta_key of ...
0
votes
1answer
20 views
Cache metadata for set of posts
I have a query that can only be done using straight SQL, but I need to loop through the returns as a set of posts. As I understand it, WP_Query automatically gets all the metadata for all the posts ...
0
votes
1answer
162 views
How to insert multiple postmeta values with one query?
I have a custom script/plugin I am using for myself that creates a post along with some postmeta information. Right now, I have multiple $wpdb->insert, but I would like to condense this down into ...
4
votes
1answer
130 views
What is the advantage of the wp_options design pattern?
As we all know, a design pattern that is used frequently in Wordpress' DB code is the idea of persisting data for a particular object (blog/post/comment), indexed with a particular name or key.
We ...
1
vote
1answer
29 views
Get a row from a separate table by matching a posts meta_key to a tables ID column
I am trying to match a posts meta_key value to a separate tables column ID and call that row/array in the single-listing.php.
I have a meta_key value that is called dot_number. The table is called ...
0
votes
1answer
61 views
Compare string with post id in wpdb and do stuff when match is found
I'm looking for some help tying in with the wpdb to compare and change certain values. I'm very novice with mysql handling so I really appreciate any help on this matter!
What I want to do is to go ...
0
votes
1answer
565 views
wpdb->get_var - count author posts, meta value
In an author.php template, i count the author post in a custom post type with $wpdb->get_var,
$post_author = $curauth->ID; //author id
$count = $wpdb->get_var( "SELECT COUNT(*) FROM ...
1
vote
1answer
327 views
MySQL Query To Select Post By Postmeta
I have two custom post types, type1 and type2. Type2 posts have a postmeta called postID that is the ID number of a post in type1. When showing type1 in single.php I want a mysql query that selects ...
0
votes
2answers
148 views
How to query and update one colum in postmeta table?
I'm trying to make a popularity calculation for all posts, based on page view and date of creation. Initially, there's a default popularity value saved in postmeta. Every hour I want to recalculate ...
0
votes
2answers
702 views
How to test the outcome of a wpdb query?
I want to get all the data with the meta key of "project_id" from post meta table. I wrote a query, it should work in thoery, but I have no way to see what I get, and inject this query to my plugin ...
-1
votes
1answer
285 views
How to get all the related ids without array?
I want to get all the post ids when the post meta includes a key of "project_id". This function get the job down, but need refine:
function get_all_ids(){
global $wpdb, $post;
$meta_key1 = ...