"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

1
vote
1answer
891 views

Pagination doesn't work

I created myfile.php with the following content: global $paged; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } else if ( get_query_var( 'page' ) ) { $paged = ...
0
votes
2answers
12 views

An archive page without post format (just standart post)

I'm trying to get posts with not marked with any type of post types (aside, audio etc). But I didn't find any solution to doin' this. I throught doin' this with custom fields but site has a lot of ...
1
vote
2answers
427 views

twentyeleven_content_nav hook no longer outputs navigation link after 3.5 upgrade

After upgrading to 3.5, I discovered that navigation has disappeared outside of the main index page. Theme is TwentyEleven and I've verified that this still occurs after disabling all plugins. ...
0
votes
1answer
660 views

Custom WP Query from meta_value stored as serialised array

I'm using a Magic Fields 2 multicheck box to store Services which can be assigned to Case Studies. The data is stored as a serialised array in WordPress, and I need some help to extract the "related ...
0
votes
0answers
23 views

Sub-menu on child pages as well as parent page

So here's what I'm trying to do: I'm trying to develop a theme that shows any sub-pages on the parent page. I've gotten this running successfully with a WP_query and a simple loop: <!--show sub ...
0
votes
1answer
47 views

Querying Multiple Categories With Different Offsets

On my website I have a "Breaking News" section which shows the most recent 4 stories in the "Breaking News" Category. Under this I have a featured news section which displays 5 more stories from the ...
2
votes
3answers
50 views

PHP memory friendly alternative to get_posts()

I was running into memory issues with this: get_posts( array( 'posts_per_page' => '-1', 'post_type' => array( 'product', 'product_variation' ) ) (there are thousands of results) just trying to ...
0
votes
2answers
21 views

Query: offset post list, unless it's a specific category

Here's my code: <?php query_posts(array ('showposts' => '1', 'cat' => '-11')); if (have_posts()) : while (have_posts()) : the_post(); get_template_part( 'content', 'archives' ); ...
2
votes
1answer
45 views

Combining two wordpress queries with pagination is not working

I am trying to combine two WordPress queries but it's not working as well as pagination. I want to display today's all posts sorted by comment count and after that I want to display all posts ...
0
votes
1answer
12 views

Post__not_in only removing first 2 pages

I am using post__not_in to remove pages from a query but it's ignoring anything more than 2 items My code: $selected_check = array(); $checks = new WP_Query( ...
2
votes
1answer
23 views

Show posts without term

I am working on a product page where I show reviews from my post type 'reviews', if the product page title matches with my term from the taxonomy 'review-product'. Example. Product page title: ...
0
votes
0answers
21 views

How to get rid of extra Untitled Article in html5 document outline when using new WP_Query?

Here is a simplified version of the code I'm using on a static homepage template made for a child theme of TwentyTwelve. I simplified some of the divs used for styling and just focused on the problem ...
0
votes
0answers
16 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
461 views

Fatal error: Allowed memory size exhausted

I have a custom .csv generator functions that basically export data from posts and its post metas. The function works fine on this WP_query parameter: Array( [tax_query] => Array ( ...
1
vote
1answer
316 views

WP_Query Pagination on multiple-loop page breaks WP or doesn't show up

The loop below is one of several on a Custom Page template, but it's the only loop that I'm trying to implement Pagination with. Once I have Pagination working for this one loop, I'll be implementing ...
0
votes
1answer
13 views

Display post format post in the sidebar

I am trying to pull posts with the post-format of "quote" on my sidebar. I'm getting the code to spit out the else statement but that's about it so far. I am working in the roots theme if that helps ...
0
votes
3answers
2k 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
1k 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 ...
0
votes
1answer
13 views

Cannot pull up posts of category on category page!

I have an extremely simple loop which I've placed in header.php: $my_query = new WP_Query('category_name=home'); while ($my_query->have_posts()) : $my_query->the_post(); whatever(); endwhile; ...
1
vote
1answer
345 views

Query multiple meta values

I'm working on a 'checkbox filter' to query posts by checked values. See this link (EDIT: As you can see there are just 2 posts in this link, as soon as the user checks for 'MINI' it gets a good ...
5
votes
2answers
204 views

Is it possible to query all posts that don't have an attachment?

I want to get a list of all posts that don't have an attachment and delete them. This question takes about getting all posts that have an attachment, but I want the reverse of it. The brute force ...
0
votes
0answers
12 views

Returning error with WP Insert without getting an error in error log

I'm checking if a key exists in my database using $wp_db->insert() and am executing code based on the result. I know that if a row already exists it will return false and I want to use that to execute ...
2
votes
1answer
327 views

Can you order posts from wp_query by two custom meta fields?

I'm working on a site that lists events. Right now this query lists events by date: $args = array( 'post_type' => 'espresso_event', 'post_status' => ...
0
votes
3answers
31 views

WP_Query posts_per_page Only Bringing Back one post

I'm trying to modify the Genesis Tab plugin to show more than one post per tab. I've tried in vain for the past hour, but my little PHP knowledge just isn't cutting it unfortunately. Here is the ...
-1
votes
0answers
32 views

Is it possible to use meta_query with both AND and OR relations? [duplicate]

$args['meta_query'] = array ( 'relation'=>'AND', array( 'key' => 'canonical', 'compare' => 'NOT EXISTS' ), array ( ...
1
vote
1answer
422 views

Multiple keyword search

I have a custom search where I want to enter a keyword or phrase into the search box, and then by pressing enter it adds it to a 'search storage' (already coded, see below). Asume I have 3 posts, one ...
2
votes
4answers
7k views

How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?

I am trying to retrieve all the images from the Gallery of a page in the order they are set in the backend. So far I have: $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query( ...
0
votes
0answers
41 views

Advanced wp_query - custom date and postname

I'm trying to write a query and sort by: custom date postname (in reverse order) because my postnames have a version string at the end and the latest entry should stay on the top of each other. ...
-1
votes
1answer
55 views

WooCommerce advanced custom filtering by attributes of variable products [on hold]

I created own solution for this. I will post it here soon. Is it possible to do extra filtering over posts this way or how should I do this? Basically, I'm doing filtering by variable products ...
1
vote
2answers
629 views

Recent Posts slider, using WP_Query(), loads duplicate sliders

I have written a small piece of code for Wordpress that will show the most recent top 4 posts in a slider (the Filament Group Responsive Carousel). It works, displaying the posts and sliding them etc, ...
2
votes
1answer
116 views
+50

WP Cron and wp_insert_post

I'm trying to insert posts using a cron job, but I keep running into errors where WP is missing functions (is_user_logged_in, wp_get_current_user). Is there a proper way to run wp_insert_post using a ...
0
votes
0answers
32 views

How to show subcategories using loop?

i am using wp_list_categories('child_of=54&title_li=') method to display all the subcategories, but it is showing only one, how can i use it with loop to show all the subcategories properly.
4
votes
1answer
46 views

How to place a loop within another loop?

I have two loops setup using WP_Query: $latest and $popular that I'm working to setup in this example layout: Latest                        ...
0
votes
0answers
15 views

How to sort post by custom table value

How can I sort my post by the maximum vote in custom table I have table like this:( user_votes) here post id 315 have votted two times so I just want to sort my posts by maximum vote. I am only ...
2
votes
2answers
346 views

Pagination problem after WP_Query with tag filtering

I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using: <?php //save old query $temp = $wp_query; //clear $wp_query; $wp_query= ...
3
votes
1answer
22 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
0
votes
0answers
12 views

WP_Query Meta_key is text value and need to sort as numeric not working

I have the following code below in my ~WP_Query`. $args[ 'meta_key'] = 'price'; $args['orderby'] = 'meta_value meta_value_num'; $args['order'] = 'ASC'; The custom field in question has historic ...
0
votes
1answer
39 views

Values inside a custom field to determine which category posts to display

I am facing a little problem whilst trying to display posts, from certain categories, on the front end. I've created a custom field whose key is 'related_categories' and I've different categories with ...
0
votes
0answers
13 views

Sort CPT by first letter of a meta field in a specific range

'I'm working on a way to display member profiles (Custom post type) sorted by the first letter of their last name in a given range. For example all members with a last name starting with 'A' up to ...
0
votes
1answer
16 views

Meta query for comparing two dates

I want to list all users who registered in between the $start_date and $end_date.I have written a metaquery,but it returns empty.Please help. $start_date = 2014-08-16 09:28:17 $end_date ...
-1
votes
0answers
28 views

Post Type query [closed]

I have created a Post type category with name vehicles.Under the vehicles i also create four type categories, 1-pantech 2-vans 3-utes 4-tippera and inserted each category data how to find current ...
0
votes
1answer
16 views

foreach,having wp_query inside, breaks after showing one result

I am trying to make category tabs that show posts from selected category tab. I have tried it my way but m getting only one post for each category, whereas it should return all post in that category. ...
0
votes
1answer
333 views

posts_per_page is not working

I have a query to display custom post type categories' posts, but I want to limit the posts_per_page to 8, so I am using the code below. Please tell me, if I'm doing something wrong. <?php $args ...
0
votes
2answers
687 views

wp-query Shortcode in Gravity Forms Notification

I have the following code that runs two wp-query loops upon form submission to display specific posts depending on the users choices in the form (The form fields are radio buttons with values that ...
0
votes
1answer
27 views

Why category__in isn't working? [closed]

I search bug in plugin (membership, provide access rules for users). The plugin adds a filter to WP_Query. All functions work, but the category filter is not working. On the generated WP_Query, ...
0
votes
1answer
303 views

Query posts by Custom Meta (checkbox) & Genesis Grid Loop

I've been trying tons of things for the last 2 days. I'm at a standstill now. I read a ton of posts here but nothing has worked yet. I have a CPT 'artists'. This CPT contains a custom field ...
0
votes
2answers
22 views

How to make “Blog pages show at most” setting not affect custom queries

I want my blog page to display 5 posts at most. But I have many custom queries (wp_query) on my site, some of them embedded together: how to make Settings > Reading > Blog pages show at most ...
0
votes
1answer
15 views

How do I get my custom query to work with search results after the first page?

I am using a custom query in order to ajax load/append additional posts instead of paginating them out like WP defaults. However, when I click the button I've made to load more posts, it loads all ...
10
votes
2answers
10k views

Meta_query compare operator explanation

I noticed that there are bunch of operator can be use for compare in meta_query. However, I am not quite sure what operator I should use, it is somehow confusing like = and LIKE operator. I would ...
1
vote
5answers
1k views

WP_Query returns no results

I'm using wp_query to create a custom query that retrieves search results but it is returning 0 results. Here is the code: $query = 's=the&posts_per_page=5&paged=1'; $custom_query = new ...