"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to Wordpress which allows users to query the posts database using a number of criteria. 2) $wp_query is the default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

0
votes
1answer
176 views

How to extract images of post and pages excluding header and logo image in wordpress?

I have tried this code to get all images from media library and i am sucessfully getting the source urls of all the images but now i want to exclude all the unwanted images like logo, header images ...
0
votes
1answer
209 views

Query Problem - Show posts within category 'x' that have a custom field between 'y' and 'z'

I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called ...
0
votes
1answer
723 views

Upcoming Event: How do I sort database by custom date field, but ignore past dates?

I am using an events plugin and struggling to get my database query to be perfect. The query is on the event-single.php template. What I need the query to do: Query the "events" custom post type ...
0
votes
1answer
199 views

wp_query and comment_parent - select only posts with top level comments

I have a custom post type of 'films', and I'm creating a number of search filters using wp_query. All are working fine, but I now need to add in an option of exclude results that dont have any top ...
0
votes
2answers
11k views

Show all products on one page with WooCommerce

I have WooCommerce running on this store. Although the default is to show 12 products on a page the client has asked for a "show all" button that will prevent the user having to use pagination to get ...
0
votes
3answers
3k views

WP_Query orderby taxonomy term value (numeric)

I have this query... <?php $press = new WP_Query(array( 'posts_per_page' => -1, 'post_type' => 'individual', 'post_status' => 'private' )); ...
0
votes
1answer
874 views

Get post info inside modal window?

What I'm Trying To Do I have set up a custom post type for 'movies' and below is how I set up the template. Basically, I am trying to get a.thickbox (in the code below) to open a modal window with ...
0
votes
2answers
633 views

What should I use, get_posts or wp_query for less CPU load?

I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get_post" and I have 3 similar codes on page: global $post; $args = array( ... ); $myposts = get_posts( $args ); ...
0
votes
2answers
2k views

How do I Use Multiple Loops with WP_Query?

Hi I am trying to add post from a certain taxonomy term to a cpt loop. The code below is the code I am using. <?php // Create empty array to store post ids in $excludes = array(); ...
0
votes
1answer
378 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
1k views

Search another database with wp_query using new wpdb

I currently have a simple wp_query search working on my wordpress site. I now want that same search to look for results in it's own database and another one on same server. I found that I could use ...
0
votes
3answers
3k views

Wp_query order by multiple custom fields?

I am learning WP_query and recently ran into a problem. I need to do a query where i first filter trough one or more custom fields, which works great thanks to meta_query. However, i also need it to ...
0
votes
2answers
844 views

Show default content if custom WP_Query has no posts

I have a custom loop to show posts that meet a certain set of $args like this: <?php $recent = new WP_Query( $orderargs ); while($recent->have_posts()) : ...
0
votes
1answer
1k views

meta_query with array as value

I am writing some PHP which allows users of my site to submit a form and query posts by their post_meta. Everything works fine except for one thing, I used Advanced Custom Fields to create the ...
0
votes
1answer
232 views

get_posts() seemingly ignoring post_type

I am trying to grab posts of post type "leads" (see below for the code I am using) however the query produced (obtained via debug queries) is including the clause 'where post_type in ("leads", ...
0
votes
1answer
180 views

Help with a query not working with custom taxonomy

The query below is always returning the latest "news" post, not the latest "news" post with the taxonomy "sotm". I have verified the details of my custom taxonomy, name is "postCat" attached to post ...
0
votes
1answer
401 views

Alter secondary loop to exclude posts from current page category

The below code is taken from sidebar.php where it outputs random posts from multiple categories and excludes the current post from showing up. This works great but how do I alter this loop to exclude ...
0
votes
1answer
507 views

WP_Query pagination using only numbers instead of /page/1 on URL

I don't get whats happening here. I'm on a child-page template, generating a WP_Query for Custom Post Types on the fly, like this: $notrel = new WP_Query(array( 'post_type' => $type, ...
0
votes
1answer
403 views

Best practice for multiple queries on page

On my WordPress site I have three categories 'moviestar', 'interviews', and 'movies'. On a 'moviestar' category page that is entitled 'Angelina Jolie' (and with a custom variable starname='Angelina ...
0
votes
1answer
240 views

Help with hierarchical custom taxonomies and permalinks…almost there

I'm trying to get permalinks working with custom taxonomies and custom post types. Following the instructions here I was able to get it almost working, but one small glitch. The code to register ...
0
votes
1answer
281 views

Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!

I have a custom-taxonomy for a custom-post-type just like categories. I've used the standard loop in my taxonomy-event_type.php template so far … if ( have_posts() ) : while ( have_posts() ) : ...
0
votes
2answers
2k views

WP_Query multiple use of relation and/or

I have 2 custom fields that I would like to do a meta query on for a custom post type: start_date status The outcome that I am looking for is (start_date >= 1332115200 AND status = 1) OR ...
0
votes
1answer
559 views

How to Check if a Child Category is Being Queried

I need to change the number of posts queried for specific categories 'Recipes' or 'Product Reviews'. The below code works great for this, I have it in functions.php: function ...
0
votes
1answer
368 views

Compare meta_query decimals not working right

I have a custom field named 'rating' that holds decimals from 1.0 to 10. I am trying use wp_query to get me all the posts with a rating of 8.0 to 10. What I have so far almost works perfectly but it ...
0
votes
1answer
746 views

Wordpress query by multiple Custom fields and order by date

So here is my query: $args = array( 'post_type' => 'Event', 'posts_per_page' => 1000, 'meta_key' => 'event_informations_show_on_the_homepage', 'meta_value' => 'Show on ...
0
votes
3answers
526 views

Using next/previous_posts_link with customised search

I have a few different searches on my website: "Species profiles" (custom post type search) "Glossary" (custom post type search) Generic, site-wide search Currently I'm using search.php; ...
0
votes
1answer
385 views

Query WP Page for Buddypress Group Home [closed]

I've created a new home template for my buddypress groups called front.php. With the code below, I've attempted to display the content of a wp page whose name corresponds to the group name. The loop I ...
0
votes
3answers
4k views

How to make WP_Query 'post__in' accept an array?

I have a function that returns a comma separated list of post ids that a particular user can access. I want to use this list in a WP_Query loop. The custom function: $array = user_albums(); foreach( ...
0
votes
1answer
887 views

How to Get All Posts but the Private ones?

I am creating a frontend mosaic view where i need to show the most recent posts. So i need to show all published posts to every visitor, but keep the private ones for the logged in users. I know how ...
0
votes
1answer
312 views

Does using a custom query_var create a security hole?

Say I put the following code in functions.php function add_my_query_vars($qvars) { $qvars[] = "new_var"; return $qvars; } add_filter('query_vars', 'add_my_query_vars'); If somebody requests ...
0
votes
3answers
4k views

WP-PageNavi gives me a 404 when using WP Query

I see that there are a lot of similar questions here at WPSE, and I've tried many of the suggestions mentioned trying to solve my problem but with no success. I have a category called News. In this ...
0
votes
1answer
385 views

Wp-query causing problems with the_content();

I'm using some code provided in an answer on here to calculate "post X of Y" and display pagination icons on single.php. It works beautifully but it's causing problems displaying the_content(); On ...
0
votes
1answer
2k views

How to create a dynamic page based on form data with a plugin?

I have a form that users fill out. When they finish, they are redirected to a 3rd party site to set up payment options. After completing the payment process, they are sent back to my site with a ...
0
votes
2answers
393 views

Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?

I have an IF statement shown below that runs one of 2 custom queries, based on the url. The problem I'm facing is if the url contains pagination such as /page/2/, my query breaks because the url isn't ...
0
votes
2answers
1k views

How to change a custom query into a standard loop?

I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP_Query while ( $the_query->have_posts() ) : ...
0
votes
1answer
682 views

Hide posts from users with a specific role

Simply put, I need to hide all posts on the frontend if they are written by authors with a specific role. The role I have created is called 'Suspended'. I'm happy with putting a simple IF statement ...
0
votes
1answer
509 views

How to order posts by custom WP role?

I currently have the following custom wp_query which displays posts from 2 custom WP roles, "custom_role_one" and "custom_role_two". It displays the posts from my custom post type of "listing". It ...
0
votes
2answers
263 views

Slow speed and high CPU usage for my code. How to improve it?

this is my code. It gets the variables from the url. It is very slow and sometimes don't even complete. How can I improve it? Note: Most of the times some of the variables will not have any value. I ...
0
votes
1answer
664 views

Display different number of posts from one category on the different pages

according with Pagination with custom loop. I use the custom loop for display flash game. For make a pagination on the page with posts from one category (mydomain/category/categoryName) I used: ...
-1
votes
1answer
38 views

query posts in wordpress

I want to filter my query results just before the_loop starts in word press. I only want the results having term_id or term_taxonomy_id equal to 1. ...
-1
votes
1answer
144 views

Query not returning CPT posts

Ouch, banging my head against a wall! I am trying to query my post type 'clips' in index.php but it's returning only posts from the default 'post'. I need some insight! What am I doing wrong? My ...