0
votes
0answers
15 views

wordpress remove where clause in taxonomy page [on hold]

My site has installed woocommerce. When I visit taxonomy page, the below SQL is executed SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = ...
0
votes
1answer
60 views

$wpdb select date range of posts

0 down vote favorite Using this SQL query to sort users by how many votes(meta key) their posts have received. <?php global $wpdb; $results = ...
1
vote
2answers
53 views

Query that loads a custom type AND posts whose ids are not inside those custom types custom fields

On my news website I have posts and another custom type called "aggregato". This type has 10 custom fields, "link01", "link02"... "link10". Both posts and aggregato has a meta key, called "home", ...
0
votes
1answer
39 views

How to avoid filling up an array each time I run a WP_query?

I am making a following user system and need some help for retrieving the users ids a user is following. At the moment I am using the following SQL query for retrieving the users ids a user is ...
0
votes
1answer
60 views

How to SQL query posts IDs by categories AND authors?

I am making a custom WP_Query and I need to come up with a SQL query that gets the posts IDs from X categories and Y authors. Then merge those IDs and put them in an array. I only need to figure out ...
0
votes
0answers
142 views

Custom WP_Query with SQL directives for getting posts by authors and terms

I am making a custom page where I need to display posts from authors and terms (categories). I tried with the built in WP_query arguments but I am not getting the result I want. So I want to know how ...
0
votes
1answer
75 views

Randomly select one of last 3 posts

ok so i have this: $args=array( 'orderby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 1, 'offset' => $offset, ); $q = new ...
0
votes
0answers
16 views

WP query taxonomies not the same as output

I'm trying to build a custom query and I need to include the current category ID. I previously had the WP_Query args as: Array ( [post_status] => publish [posts_per_page] => -1 ...
0
votes
0answers
15 views

How to change location, charset in Wordpress query [duplicate]

I have strange question. How Can I change or set a sql char set in wordpress. In wp_config.php I have: define('DB_CHARSET', 'utf8'); define('DB_COLLATE', 'utf8'); In my plugin I have this: global ...
0
votes
1answer
47 views

How to return value from sql and display it

In ordinary php I don't have that kind of problem I think but in WP this is a different story. I have query and I want return one value from "liczba_wodo" column. global $wpdb; if ...
0
votes
0answers
80 views

orderby in WP_query doesn't works

I thought that this already works but now I tested it and it seems that it no longer works. I have this code: wp_reset_query(); $args=array( 'posts_per_page' => 3, 'meta_key' => ...
1
vote
4answers
182 views

wordpress ajax relationship query

Using the relationship field from Advanced Custom Fields I link artists to events. Both these artist and events are custom post types. For each event, the post IDs of the related artists are stored in ...
2
votes
2answers
218 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 ...
1
vote
1answer
2k views

Using OR conditions in meta_query for query_posts argument

I have searched high and low for this but I cant seem to locate anything. I am trying to filter some results and when I make an args array like this and pass it to query_posts I noticed that the ...
1
vote
2answers
573 views

Optional Meta Query

I have places stored as posts in WP's posts table. I am doing some geo-locating using Geo Data Store (http://wordpress.org/plugins/geo-data-store/). This is working great for me, as I can currently ...
0
votes
1answer
542 views

WP_Query with several meta_query-statements and order by meta_value

This is my query: $the_query = new WP_Query( array ( 'post_type' => 'pass', 'posts_per_page' => '-1', 'post_status' => 'publish', ...
2
votes
1answer
101 views

Filter WordPress posts by between parameter

How to filter WordPress posts by a taxonomy and between parameter? Consider a mobile website with "memory size" taxonomy, I need to show posts that have more than 256 mb memory and less than 768 mb. ...
1
vote
1answer
648 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 ...
1
vote
0answers
84 views

Meta Query And/Or

My question is very similar to Meta Query with AND & OR? . This question was answered in 2011 by @Otto. With the exception that my logic is different. I want to query, for example, posts with ...
1
vote
1answer
336 views

Recommended way to drop a pending query (in pre_get_posts)?

It looks like an e-commerce plugin's core query will be of no use to me in one particular template so I would like to discard it completely in favor of my own WP_Query loops in the template. It's not ...
0
votes
1answer
361 views

Wordpress SQL JOIN query

Hi Im trying to run 2 querys in the same query call. // send the query global $wpdb; $commentQ = "SELECT * FROM $wpdb->comments " . $whereClause . $orderBy; $comments = ...
2
votes
2answers
256 views

What is an efficient way to query based on post_meta?

The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a ...
0
votes
2answers
69 views

Query is not work

I use this codes in my functions.php to track post views. /* Functions to track Post Views*/ function getPostViews($postID){ $count_key = 'post_views'; $count = get_post_meta($postID, $count_key, ...
0
votes
1answer
391 views

How to get from sql query page id and retrieve it url and title

Conditions: Page have template, for example: /* Template name: News */ Explaining: We have many pages, and one page with assigned template (/* Template name: News */). I want on main page ...
2
votes
2answers
2k views

Improving WP_Query performance for multiple taxonomies

I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I'm using a WP_Query like so: ...
2
votes
3answers
5k views

Pagination with custom SQL query

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working ...
9
votes
2answers
16k views

WP_Query with “post_title LIKE 'something%'”?

I need to do a WP_Query with a LIKE on the post_title. I started with this regular WP_Query: $wp_query = new WP_Query( array ( 'post_type' => 'wp_exposants', ...
3
votes
1answer
966 views

Is it possible to wrap Geo Location search around WP_Query?

I'll just like to add that I have a current working solution in place and works well but I'm looking for ideas of being able to do it better or cleaner if possible. We have hundreds of properties in ...
3
votes
1answer
188 views

How to make an activities stream mixing posts and comments?

What I'm currently trying to make is an activities stream wich list : The posts, the comments, both mixed between them and ordered by date. My idea is to make two queries, but i don't know how to ...
1
vote
1answer
1k views

Order query by meta_value with multiple custom fields

I would like to get ordered all my posts with multiple cutom fields (WordPress 3). Exemple, I've 2 custom couple meta_key/meta_value : " order_submenuexpositions / numeric " " ...