"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
1k views

Using in 'category_name' in '$query->set();'?

Here's the function I have in my theme's functions.php: function better_editions( $query ) { // Categories act as 'Editions' on my site $get_edition = get_query_var( 'category_name' ); ...
1
vote
1answer
1k views

How to paginate attachments in a secondary query as gallery?

I have this code that shows all images attached to my post-type. Is there a way to paginate those? I have like 25 pics and I wan't to avoid scroll as much as I can. Code: <div class="galleries ...
0
votes
1answer
31 views

How to get category pages to look like a certain archive page?

I'm not sure if this question has been answered, I'm not sure of how i should have even worded this question but... I have a custom post type called videos and the style of the archive is different ...
0
votes
1answer
92 views

Custom filter for main search: how to exclude specific post_type from search results

Is there a way to use WP_Query's method, set(), in order to exclude a specific post_type from a global search. Here was my unsuccessful attempt: function _search_all($query) { ...
0
votes
3answers
2k views

Sort posts by category name and title

Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category: A CATEGORY – A post beginning with a – Because I want to be ...
0
votes
1answer
248 views

WP Query get posts by specific author IDs if one of several logged in authors

I have a custom template page where posts are shown from authors 1,2 and 3. <?php $the_query = new WP_Query( 'posts_per_page=-5&author=1,2,3' ); ?> How can I use get current user in this ...
0
votes
0answers
393 views

Pop up showing same content on all posts display.

I have created a blog template, to show a custom posts in a grid of 3 columns. like this <ul class="grid effect-6" id="grid"> <?php ...
0
votes
2answers
122 views

Sort by name - second wp_query

I am using the code below to sort by name based on taxonomy and then list the posts within each taxonomy. First query works ok for alphabetical listing of taxonomies. The problem i am having is that ...
0
votes
1answer
38 views

Can't get simple meta queries to work

I cannot get this simple meta query to work and I have no idea why. I have a custom post type registered, called 'ef_project'. I have a few test posts created using post type, each with a postmeta ...
0
votes
1answer
160 views

Retrieve posts in custom post type and specific taxonomies

I'm struggling with what seems like should be so simple looking at the codex. I have a custom post type, let's call it 'portfolio'. A custom taxonomy for that, let's call it 'clients'. I can use ...
0
votes
0answers
142 views

WP_Query with intersection of post meta field and user meta field

On the site I'm building, each post has a serialized array of strings. Let's say post ID 1234's value for my_site_teams is array( 'Chess', 'Cheerleading', 'Football' ). Each user also has a ...
0
votes
1answer
87 views

How to query post ids liked by the Author

I'm using wti_like plugin and this is how i get the number(count) of post liked by the author // Get the author object $author = get_user_by( 'slug', get_query_var( 'author_name' ) ); // Get the ...
0
votes
1answer
109 views

'paged' in wp_query doesn't work

I try to add a code to my wordpress blog show previous posts(in a previous page). I try this code but it don't work: <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $args = ...
0
votes
2answers
44 views

Get Posts by IDs (optionally)

I want to check if a variable contains list of post IDs, then I want to query the posts of those IDs only, but if that variable is empty then I want to display all posts. Problem: If I supply IDs to ...
0
votes
2answers
235 views

Set colors depending on category

I have this function which outputs the last 6 posts of categories 1 and 2. <ul> <?php query_posts('cat=1,2&showposts=6'); ?> <?php if ( have_posts() ) while ( have_posts() ) : ...
0
votes
1answer
46 views

Is This Code Efficient - Or is there a better way?

I have a RECIPE WP site, that is using CPTs to handle the recipe content. The client wanted an A-Z Directory listing of all recipes. I came to Wordpress Answers and found the following code that ...
0
votes
1answer
692 views

Show a 404 error page if Public query variable's value doesn't exist?

Public query vars are those available and usable via a direct URL query. On my site, I've created some custom URLs with their own query variables like so: ...
0
votes
1answer
358 views

How WordPress attaches its Featured Images with posts?

I'm working on a WP_Query(), where I'm trying to fetch all the images using 'post_type' => attachment and 'post_parent_in' => array( 1688 )(I want to pass some more post_ids) along with other ...
0
votes
1answer
213 views

WordPress Query String: get_posts('cat=5') vs WP_Query( 'cat=5') vs URL: /site/?cat=5

We can filter our posts with a URL query string: http://mysite.com/?cat=5 We can also use a similar syntax for get_posts('cat=5') and new WP_Query('cat=5').** get_posts('param=value'); just passes ...
0
votes
1answer
149 views

Getting titles from an array of IDs

I have two custom post types called actors and movies. In movies, I have a custom meta box that got data from actors post type. When an actor is selected in movie post, the values (post_id, meta_key ...
2
votes
2answers
838 views

Custom query form submission pagination

There is a question very similar to mine, which can be found here. The difference with my question is: my search form is on several pages (page.php and single.php) and I don't use wp-pagenavi. I've ...
0
votes
1answer
68 views

Sort Posts with custom meta key by default which is currently set as optional

I'm new to Wordpress so please bear with me. Please check this link The posts are currently sorted by date. But if you mouse over on Latest Articles you see there are other options for sorting like ...
1
vote
1answer
232 views

How to access WP database inside ipn.php? [duplicate]

This is my ipn.php that is sending a mail to the user when PayPal transaction is completed. The problem is that I also need to change the state of the order in the WP database and not just send the ...
0
votes
1answer
196 views

wp_query pagination links producing 404

I've searched thousands of related posts and can't seem to get the pagination to work on this loop. As soon as i click next page i get a 404 //get the search term if (!empty($_GET["s"])){ $s = ...
0
votes
1answer
181 views

How to retrive Custom Post Type Meta Fields in Custom WP_Query

Can some one let me know How I can render the Custom Post Type Meta Fields (Meta-boxes). I have a Custom Post Type Called "News" and I successfully added a Metabox to my Custom Post Type called "News ...
0
votes
0answers
44 views

Custom list of categories that is sortable by count

So I am attempting to use bootstrap with wordpress. Inside my left column my design called for a large box and then 4 smaller ones below. Those boxes would hold information about a category. There ...
-3
votes
1answer
45 views

How can I filter a query by post id?

In my wp_postmeta table, I have the following values: I'm trying query the posts whose ID lie in the meta_value column associated to a given post (the current post being viewed). For example, ...
0
votes
1answer
382 views

Exclude most recent posts from specific category in wp_query()

I have a featured posts slider, which uses the 'featured' tag. I have a query for this which grabs the 3 most recent posts with this tag and shows them in the slider. Below this, I have a list of 10 ...
0
votes
1answer
27 views

Why is the value zero going in my custom database table?

I am working on a task where I have to insert a customer into database table in WordPress. It's a custom table so I used a template file and applied a wp_query. The rest of the data is getting into ...
1
vote
1answer
88 views

Order posts by 2 custom fields and if one custom field is zero orderby another custom field

I have a really tricky function to implement and couldn't find a way by searching Please see details below I have a custom post type called "accommodation", and for this post type, there are 2 ...
1
vote
0answers
439 views

Pagination with custom query, custom search form, single and pages, ajax and no plugins

I've read a lot of posts here about pagination with custom queries and tried the suggested answers (like this one). It seems however that my situation is a little more complex, and in the existing ...
0
votes
1answer
35 views

Using WHERE on a WP_Query

I have two custom post types: Books and Subjects. For this projects, I'm using Super-CPT to create custom post types: $books = new Super_Custom_Post_Type( 'book', '', 'book', $register = array( ...
0
votes
3answers
43 views

Include one page/post into query which is already returning posts

I have my news query which is on my index file. I want to include a post into this query which is infact a page. Is there anyway to do this? <?php query_posts(array( 'posts_per_page' => ...
0
votes
1answer
553 views

Query custom taxonomy for category including children

I've using the Events Manager plugin which creates a custom post type of 'event' and a custom taxonomy called 'event-categories'. I have the category 'courses' which has an ID of 43. I also have a ...
0
votes
0answers
94 views

Meta_query weird behaviour

I have a custom field called date_from. Dates are stored in the yymmdd format (eg 20131104). When I use a meta_query to find posts in a specific date range the query works as expected, but when I use ...
0
votes
2answers
720 views

wp_query within function within wp_query

I have a query which looks like this: $args = arguments for the query $query = new WP_Query($args); while ($query->have_posts()): $query->the_post(); $post_id = get_the_ID(); echo ...
0
votes
1answer
52 views

Trying to use WP_Query to display a custom post type

I'm trying to use WP_Query in function.php to display a custom post type on a certain page. I just can't seem to get it to work, can anyone see issues with my code? nothing is output at all and there ...
1
vote
1answer
379 views

using wp_query to return posts w/ comment count > 0

I've looked at numerous examples of wp_query and can't figure this out. If the thing I was comparing were a meta value then I could to a meta query, but apparently you can't do a compare with a ...
0
votes
1answer
63 views

I am officially missing something about transient posts

I have no issue creating transients. What I have an issue with is pagination - and I have made posts on it before and every one sates that the query must look like, for example: $queried_post ...
0
votes
1answer
314 views

multiple values in an array for category__and does not work with WP_Query

So I'm looping with WP_Query and here is my code: $country_posts = new WP_Query(get_direct_children($continent_cats)); if ($country_posts->have_posts()) : while ($country_posts->have_posts()) ...
0
votes
0answers
184 views

Why is WP_Query's meta_query not filtering results?

I am working on a wordpress site that utilizes WP_Query to find songs based on their category, tags, and other things in a tax_query, but it also groups in a meta_query which (should) find songs based ...
0
votes
1answer
244 views

Printing direct descendants of a category with WP_Query

So I'm having trouble printing just the direct children of a category on a page. Here's my code: $category_id = get_cat_ID('destinations'); $args = array('child_of' => $category_id); ...
0
votes
3answers
681 views

Pagination broken when merging search results with additional WP_Query

On the search results page (search.php) I would like to perform an additional WP_Query to keep a specific order of search result types e.g. search results from authors should always be shown before ...
0
votes
2answers
107 views

Make assigning post to a specific category equivalent to assigning it to all categories

Allow me to explain with an example, for the sake of clarity. Please take the time to read it all to get a good idea of what I am exactly after. On my WordPress site categories are used as Editions ...
0
votes
0answers
168 views

How to Display Custom Post Type's Gallery (images ) in Through WP_Query

I am trying to load an Image Slider images from a Custom Post Type image Gallery Feature. For example let say I have an Custom Post Type called banner which I can load images to it's Gallery and I ...
1
vote
1answer
164 views

How do I use WP_Query to get a range of posts with custom fields that have numbers with letters in them?

What I'm trying to do I am using WP_Query() to get posts based on their range for example: $args = array( 'numberposts' => -1, 'post_type' => 'page', 'posts_per_page' => -1, ...
0
votes
1answer
294 views

Pagination works in custom query loop but it doesn't work in shortcode

It is possible for shortcodes? Paggination works fine on custom template page.But I want to display the posts with shortcodes. Posts are displayed well.But pagination works incorrectly.The same posts ...
5
votes
2answers
2k views

How to do a wp_query using “BETWEEN” with two meta_values?

I'm starting with Wordpress, already achieved some queries, but this one... ugh! It's being a pain to me! What i want to do is this part of query: " ... WHERE "VALUE_THAT_I_WANT" BETWEEN ...
0
votes
1answer
475 views

Shortcode does not display pagination [duplicate]

I use a normal page for display posts by a shortcode.On pages posts are displayed correctly,but doesn't echo the next and previous posts links and the page content is displayed below shortcode ...
1
vote
1answer
384 views

Most commented last 24h, week, month, year and all time - posts_where

I've removed my old post here, as the posts_where method is outdated. Thanks to kaiser, this is now how easy it is to list most commented posts within a certain time span: <?php $popular = new ...