The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
22 views

How to search for posts IN OR title OR content OR author?

I have looked at many posts and questions regarding searches for custom meta, but I want to search for posts and include those if the search query matches an author name. I have come up with the ...
0
votes
0answers
7 views

How to add custom where condition in user listing at admin page?

I have found a posts_where filter to add custom where conditions in listing posts. Like this is there any filter to add custom where condition for listing the users? Thanks
0
votes
1answer
21 views

Use posts_where to exclude posts ids from wp_query

I want to use posts_where to exclude an array of posts ids from all queries in my site. The array containing the posts ids depends on the user that is logged in. Can someone please tell me how to ...
0
votes
0answers
25 views

Check if the value of “meta2” is smaller than the value of “meta1”

function my_query($where) { global $wpdb; $where .= " AND SELECT $wpdb->posts.* FROM $wpdb->posts AS p, $wpdb->postmeta AS pm1, $wpdb->postmeta AS pm2 WHERE p.ID ...
0
votes
1answer
54 views

Custom post type filter by post meta - not returning correct counts

I have a custom post type product. And what I did, I made a custom filter function based on the custom post's meta data using posts_where filter. It's working but I noticed the post count is not ...
0
votes
1answer
73 views

using posts_where for meta data on pre_get_posts

Let's say you have some code which filters posts by using pre_get_posts e.g. add_action( 'pre_get_posts', 'be_exclude_category_from_blog' ); function be_exclude_category_from_blog( $query ) { ...
1
vote
2answers
2k views

Prevent pre_get_posts filter on specific post type

I am running into one issue with pre_get_post filter. Actually I have 4 post types. Post, Pages, Events, and Venue. I created one custom field called city for event and venue post type. When ...
1
vote
1answer
471 views

How do I create my own nested meta_query using posts_where / posts_join?

Some of my posts (not all) have a price as a meta key/value. Today I use the pre_get_posts action so that my users can search for prices that are between a certain value. This is the code that I'm ...
1
vote
1answer
118 views

posts_where Fails with More than One Custom Field in Query

Querying either of the 2 fields individually gives the expected result (posts are displayed). But, when both fields are included in the query (ex = 'foo' and 'bar' shown in below example), then no ...
3
votes
2answers
246 views

Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows: class ...
0
votes
1answer
485 views

apply custom where to the default $wp_query

I can read on the docs that if I need to perform a custom WHERE on WP_Query I need to do the following: // Create a new filtering function that will add our where clause to the query function ...
1
vote
1answer
284 views

Get Posts updated or published within the last x hours

Okay, I'm trying to get posts that have been published within the last x amount of time, options being 8, 24 or 72 hours. I have the variables being passed to my featureHandler.php via ajax, then ...
2
votes
1answer
113 views

When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?

This question is a follow up to a question I recently asked. I've implemented what seemed to be the only solution, and it seems to work (YAY!). I just need to verify that: This is really the only ...
0
votes
2answers
1k views

Using dynamic conditions in 'posts_where' filter

I have the following code which gives be posts that are published in the last 100 days function smbd_cats_by_days ($where = '') { $where .= " AND post_date < '" . date('y-m-d', ...
2
votes
2answers
627 views

Custom time range for the posts_where filter

I'm creating a function that displays the most viewed posts and would like to be able to show posts based on how old they are. Modifying the query is not really a problem. But since I can't pass any ...
2
votes
1answer
1k views

Search ONLY by meta key / meta values

I'm almost there on this one. On functions.php i have this: function base_home_product_post_type( $query ) { if($query->is_search() && $_POST['box'] == 'sku') { ...
4
votes
0answers
139 views

Custom query incorrectly returning everything [closed]

I'm missing something somewhere, but I cannot connect the dots. Everything outputs properly except that the query returns everything from the DB, not just posts. Can anyone spot a reason for this ...
1
vote
1answer
670 views

Compare post-IDs within WP_Query? (Less than / Greater than)

Can I use WP_Query to only query posts less than (or greater than) a given post ID? $filtered_query_args = array( 'post_type' => 'projects', 'order' => $prev_next=='next' ? 'DESC' : ...
1
vote
1answer
609 views

Including Custom Meta with posts_where query

I have been looking around to see how to do this but the solutions i've found don't seem to be working for me. I'm making an AJAX powered search for some wordpress custom post types. I have got ...
1
vote
2answers
847 views

Only retrieve posts where post_excerpt has been filled out

I'm trying to use get_posts to only return posts that have an excerpt. Done lots of searching and have been trying to use "posts_where" filter on the query but my SQL is lacking. This is what I'm ...