"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
0answers
16 views

Query of all pages, including children, ordered by meta key

I'm saving a revised date as meta_value on every page and I want to display them ordered by the date in a list in my plugin screen. How to both include child pages (can be 4-6 levels deep) in the ...
0
votes
1answer
31 views

Why wp_query return 1 row if i have 3 row pass in it

I have this query to return the post $sitens = new wp_query( array ( 'post_type' => 'post' , 'post__in' => array($post_id) ) ); if ( $sitens->have_posts() ) : while ( ...
-1
votes
1answer
32 views

Query custom post types by meta field in a term from custom taxonomy

I need to retrieve all custom posts that have terms from custom taxonomy assigned to them. To be more precise: There is advertisers_cats post type that has terms assigned from custom taxonomy ...
0
votes
0answers
27 views

How to pass taxonomy terms to WP_Query along with $args?

I created a cpt and custom taxonomy associated with it. Lets say custom taxonomy name is Sports. I added terms to it - football, basketball. Now, i want to fetch post titles tagged under football ...
0
votes
0answers
13 views

Child pages of child pages

I am having problem listing child pages of my sub pages. Here is my code <?php // Set up the objects needed $id = get_the_ID(); $args = array( 'post_type' => 'page', ...
1
vote
1answer
30 views

Get the next event using date_query

I created a CPT called event and want to make a query to show the next future event, based on it's publish date. Here is the WP_Query args: $today = getdate(); $args = array( 'post_status' => ...
0
votes
1answer
33 views

Finding the next 5 posts

On my single.php where I am calling my post I am wanting to run a query where I can catch the next 5 posts (chronologically). I know how to do everything except figure out a way to specify the 5 ...
0
votes
1answer
47 views

Most popular post for last 7 days

I need to change the most popular post widgets with date restrictions. For an example, how should I get most popular posts(post_views_count) of last 7 days. original query, $popularposts = new ...
0
votes
0answers
41 views

order posts with conditions & meta_key merge

i want a code to orders my blog posts using a "conditions" & combinaisons of 2 meta_key so details: if ( postviews < 20 views in exmple) ==> those posts order with date ==> here ...
1
vote
1answer
44 views

How to get a category in a list item class

I am need to know how would I get the category to be dynamically input in a WP_Query This is the code I am using: <li class="<?php the_category(' ')?>"> but the output is breaking. ...
0
votes
0answers
35 views

Custom query with pagination on home page

My home page need to retrieve some posts and break them into number of pages, so that I can load them using infinite scroll plugin. I have tested my query, it works as expected. however I can't seems ...
0
votes
1answer
52 views

Can I run multiple queries with $wpdb->prepare?

I have a query(actually multiple queries) that runs perfectly in phpmyadmin, (I've also tried get_var in place of get_results, but I think I might need an alternative to $wpdb->prepare. How can I ...
0
votes
0answers
33 views

Calculate top authors on the basis of Post Views

I wanted to calculate the Top authors on the single.php page according to the average of the posts views. I have created a function which is calculating the average of the total post views of a ...
0
votes
1answer
18 views

Link to date_query results in Wordpress

I have this line of code: $args = array( 'date_query' => array( array( 'after' => 'January 1st, 2015', 'before' => 'February 15th, 2015', ...
0
votes
3answers
25 views

Get next/prev image/attachment in time with date query

I have a big amount of images in WP, that are not attach to any post. They are grouped in custom taxonomies (ignored in code below). The images get uploaded to WP in random order and the post_date is ...
0
votes
2answers
34 views

Sort Wordpress Posts Meta value by Week not Day

Right now I have a metakey called 'epicredvote', it sorts my posts by this epicredvote number. It is doing it on a daily basis at the moment, so if I have 2 posts the post with the highest epicredvote ...
1
vote
2answers
63 views

Order by menu structure

As I'm making one page website. Here is question I asked earlier: Calling Specific Pages with wp query Part II As I'm calling all pages by WP_Query which is "order by = ASC" I want to call it "order ...
0
votes
1answer
97 views

WordPress meta_query not working

I am having issues with a meta query on a custom post type. The following arguments are set: $args = array( 'post_type' => 'wp_comp_entries', 'posts_per_page' => -1, ...
5
votes
1answer
87 views

Select all in parent category, group by child category?

I am trying to format a custom post type for a "series". Each post is an Episode, each Episode belongs to a Season, and each Season belongs to a series (just like a TV show). I have the following: ...
0
votes
0answers
44 views

Select posts with a custom taxonomy as a custom field

I am using woocommerce, so I have the product category taxonomy (product_cat). On a product category page, I would like to display the posts that are in that (product) category. That will be the ...
0
votes
1answer
19 views

parse_tax_query causing Navigation Menu To Disappear

I am using the following snippet to modify a query... function no_child_terms($query) { if( !is_admin()) { $query->tax_query->queries[0]['include_children'] = 0; } } ...
0
votes
0answers
80 views

Include data from custom table in WP_Query

I'm building an Estate Agent website. They have a system where they add their available properties and sends them all to the main property portals. As part of this, the system also sends all the ...
0
votes
2answers
48 views

Optimising amount of calls to custom fields

I have this code fragment in my codebase: foreach($this->adverisers as $adveriser) { $this->data[$adveriser->name]['image'] = bfi_thumb(get_post_meta($adveriser->ID, ...
0
votes
1answer
64 views

How to delete only user meta value (not key) from usermeta table in wordpress?

I store multiple image in media library and save its id in wp_usermeta table. my metakey is 'images' and meta value in like '279,280,281'. Now I get the image from table like this: <?php $images = ...
0
votes
2answers
35 views

Wordpress altering my custom query, How to fix it?

I am querying for most popular posts by custom view count by using the custom query below, <?php $mostpopular_args=array( 'post_type' => 'post', 'orderby' ...
0
votes
0answers
45 views

How to make search for posts using get method?

So I am building a WordPress theme for myself to meet my needs, so what I am looking for now is make a search using a get method in PHP. If my URL is something like this : ...
4
votes
2answers
74 views

Display several random posts, but make sure a condition is met

I have a custom post type for a group of people (employees). At first, I needed to display 7 random employees. That was easy <?php $args = array( 'post_type' => 'employees', ...
2
votes
1answer
93 views

WP_Query sort by comment meta data

Is it possible to use the WP_Query class to order by comments meta data fields?
0
votes
0answers
60 views

Sorting Posts with meta value not working

I want to retrieve most popular posts based on 'view_count' meta value, the below code doesn't seem to work, I am getting some random posts, where am I doing it wrong? <?php ...
0
votes
1answer
30 views

Use Tags to Query Associated Multiple Posts and Get The Average Of Custom Field Values

I have created a custom post type named “Rating” that I’m using to add customer rating sections to my website. Each rating post has the ability to have a: Title Comment section Featured Photo ...
0
votes
0answers
16 views

Empty result when trying to fetc post in the future

I am trying to fetch a single post that is either scheduled or published using a custom WP Query. The query is running asynchronously. However I get no results. Here is my code: ... $args = array( ...
0
votes
1answer
11 views

Display posts from catagories

I am using an option framework. This saves catagory ids.To get ids I have done $cat = $atts['post_catagory']; var_dump($cat); The var dump result is array (size=2) 0 => string '1' ...
0
votes
1answer
40 views

Issue in If else condition [closed]

I'm calling my all pages on one pages as a section. Here is my code: <?php $args = array( 'post_type' => 'page', 'orderby' => 'ASC', ...
0
votes
1answer
36 views

How to view all posts of current day as default in admin

I want to to show all posts of the current date by default (without clicking the filter button) in WordPress admin posts list screen. I have used this code in functions.php and it works almost. The ...
0
votes
1answer
25 views

Getting attachments by meta value

I'm stuck at a very simple point: I need to get all attachments by a custom meta key (and value). I'm developing a short code, so it has to work on every possible page. What I've tried so far: $args ...
1
vote
4answers
79 views

How to limit the number of post that WP_Query gets?

I have been researching on Google and WPSE and the only thing I see repeatedly is to use showposts, that is deprecated. I am familiar with WP_Query, and I thought that if I set posts_per_page to my ...
0
votes
0answers
67 views

How to get all tags of a custom post type by id

simple question, how to get all tags of a custom post type by id? post_type=product. i have tried with http://codex.wordpress.org/Function_Reference/wp_get_post_tags in my post loop and the print_r ...
0
votes
0answers
19 views

How can users subscribe to searches

How to allow users to subscribe to search queries (for example a user search on the website, using the search form, for "green apples"), and send daily email alert to subscribers when new posts appear ...
0
votes
0answers
21 views

PHP Wordpress Monthly Top Author in Sidebar

Im trying to show List of Top Author by Property Update Count (Monthly) in my sidebar. How to adjust this php code. This php only show AUTHOR list in my sidebar, not sort it by Monthly Property Update ...
0
votes
0answers
33 views

Why is $wp_query fetching nothing?

I have created a ajax file from where response will return named "ajax_show_nxt_cat.php" and here I want to list all post using $wp_query but when I try to print the $wp_query, it returns nothing. I ...
0
votes
2answers
74 views

WP_Query with multiple meta fields filter?

I have the following query but it is still returning results which include posts which have a meta value of 'deal'. Any Clues on what am i missing in this $args = array( 'post_type' => ...
0
votes
2answers
31 views

How to query images from a post to use in a slider

I am trying to pull images as attachments from a particular post (custom post), ...and I'm using the example within WordPress codex codex example to display all images as a list ...except the images ...
0
votes
1answer
51 views

How to query post into a complex slider

I'm trying to query post into a slider. Here is the HTML Markup for the slider. Each slide has slide and a relating thumbnail. <div id="example1" class="slider-pro"> <div ...
0
votes
1answer
26 views

Using custom taxonomies in a query

I'm using a plugin (IssueM) which gives the "articles" post-type a custom taxonomy called "Issues". I'm trying to return all "articles" which have the taxonomy issue-one set (which is the slug name). ...
0
votes
1answer
73 views

Custom Post Type + Category archive

I have created a WP stack with 3 post types: 1. Post (default) 2. Event 3. Place These 3 post types share the same taxonomy, that being the default WP category, here are some example categories: ...
0
votes
2answers
70 views

Specific loop in Shortcode

I'm making shortcode and I'm stuck here. Here is code: add_shortcode('service-shortcode', 'service_shortcode'); function service_shortcode($atts) { extract( shortcode_atts( array( 'title' => ...
0
votes
1answer
33 views

Calling specific page with wp query

I'm making one page website and I added a custom field on "Page" post type that asks "Use this page as a section:" Yes or No(with dropdown). I called all pages on template-onepage.php(custom template) ...
1
vote
2answers
27 views

Which custom query am I in and how can I access its properties & methods?

Sometimes there's no way around creating a custom query, but when I do and then loop through it, I often want to use get_template_part() within the custom query loop to pull in a template I already ...
0
votes
1answer
92 views

WP_Query() with custom post type and taxonomy — get all terms?

I have the following custom post type: lesson custom Taxonomy: subject which contains terms like math, reading, etc.) I have configured my page so that the user may filter the results by ...
0
votes
1answer
61 views

Every second post different class in blog view

To assign different classes to every 2nd post in blog view in WordPress adding this code into function.php was suggested as solution. Most people claim it is helpful, but to me it just adds odd at the ...