"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
5 views

WP JSON REST API (Ryan McCue) how to query posts with specific meta data with 'AND' relation?

I use Wp_query class to query my posts. 15 posts are in a template fetched on page load and their filtering works fine. Infinity scroll fetches for other posts using JSON restful services. The filter ...
0
votes
0answers
3 views

Swap Images when selecting a different category

Here's what I'm trying to accomplish. The end user uploads a featured image of the auction item. This item is uncategorized. When they select the category "Picked" I want the image to swap out with a ...
0
votes
0answers
7 views

display post of the year/month/week in slider for archive template

I'm building a archive template, which show the post by year; month; and week. However, this archive template has a slider, which as the moment display the last post created - so it doesnt match the ...
0
votes
0answers
12 views

Loop through multiple custom fields with increasing number

I have a problem with custom fields that I have been trying to figure out for a while, but with no luck. I have a section on the site I'm building that let's the users publish content form the the ...
0
votes
1answer
14 views

How to set parameters for search loop?

This is the loop from search.php file: if (have_posts()) { while (have_posts()) { the_post(); I tried to set parameters like this: $wp_query->set('post_status', 'publish'); ...
0
votes
0answers
32 views

dynamicaly populate a WP-Query Argument

Hi Ive the following code for a single Taxonomy term template, its all working fine, however i'd like to adapt it somehow to get the argument 'term' dynamically, so get the current term, update the ...
0
votes
2answers
27 views

Comment count same for every post in homepage WP_Query

I have a WP_Query on my homepage template that works just fine for get_the_title() and MANY other functions for each post in the loop. However, any way of getting the comment count just grabs the ...
0
votes
1answer
35 views

Get author meta data with no published posts in author.php?

Unfortunately the following codes only echo the spcefic default and custom author datas if the author has at least one published post :( <?php the_author_meta('description'); ?> <?php ...
0
votes
0answers
15 views

Sorting with custom field and 'comment_count' - orderby

How can I also add comment_count to my existing query? Below query works fine and sorts the archive with highest rating_avg only, I would like to sort my archive using rating_avg first and then the ...
1
vote
3answers
27 views

Using meta_query with multiple keys and compare values

I suspect I may be asking for the moon on a stick with this, but: I have a filter for my shows custom post type. The filter uses standard taxonomies attached to shows, but also allows the user to ...
0
votes
2answers
43 views

Set post number to single posts

I have a function that I am using to number posts in a category. It is in my function.php and looks like this: function get_episode_number($postID){ $options = get_option('theme-opts'); $opts_cat = ...
0
votes
0answers
16 views

$wpdb error : call to a member function insert() on a non-object

I'd like to add data to my custom wordpress table of my plugin, here is my code: <?php global $wpdb; $data = $_POST['name']; $wpdb->insert('ct_data' , array( 'name' => $data ), array( "%s" ...
0
votes
1answer
39 views

Comparisson between date() and a date from wp_postmeta

I am using the calendar plugin: "The Events Calendar", and is trying to get the events that are done. I can't see what it is that I'm doing wrong, but I'm pretty sure that my meta_query is wrong, ...
0
votes
0answers
24 views

WP_Query by a category id and a custom post_type

I need to query all posts that belong to a given category (default, not custom) and a custom post type. As simple as that. The fact that it doesn't work, to me, is ridiculous. Unless I'm missing ...
0
votes
0answers
18 views

pre_get_posts filter meta_query without conflicting existing meta_query

I have a meta_key on all posts that is designed to check the current user role and only return the post if the user has an acceptable user role. The problem I am running into is that my meta_query ...
0
votes
1answer
9 views

WP_Query and polylang issue

In the theme I develop, I have a template showing 5 posts using the standard loop: <?php $my_query = new WP_Query('showposts=5'); while ($my_query->have_posts()) ...
0
votes
0answers
20 views

Sub-Categories in query

I have to list all products subcategories but with pagination. I only know this method to display custom taxonomies: <?php $terms = get_terms('product_cat', array('parent'=>40)); foreach ...
0
votes
0answers
22 views

Query stopped working

The following code stopped working, not entering the while loop at all although there exist 'staff' posts. How can I start trying to find out what's going on? Only think that's changed I think is I ...
0
votes
1answer
17 views

WP_Query for attachments without duplicating post_parent and displaying tagged image

I've tagged a number of media uploads on my site with the various products' names which are featured in them. The goal is to get a list of the posts which have been tagged with each product name, but ...
0
votes
1answer
18 views

Unable to get all tags from specific categories

Page in question. I'm trying to use a WP_Query(); targeting specific categories and displaying all the tags used for posts within those categories. I noticed that some tags, like truffles aren't ...
0
votes
0answers
13 views

how to place page navigation on a specific page at the end of posts from specific category in thesis theme

In single page of wordpress site I am trying to show 10 posts from a specific category. At the end of the list of 10 posts I want to show page navigation so user can navigate to old posts of this ...
0
votes
0answers
25 views

return wp query results in a shortcode

I am using wp query results in a shortcode, and right now I am echoing out the stuff I need, or just using wp functions (title(), the_content() etc.). The problem is, if I put that shortcode in a ...
1
vote
3answers
34 views

WP Query post meta value

I'm trying to get posts which have applied the meta value trainees. $args = array( 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', ...
1
vote
1answer
34 views

Paginated pages are showing correct content but pagination links are not

I am using a custom WP_Query to display posts on static front page. and generating numbered pagination links with paginate_links functions. This is the code I have... $latest_args = array( ...
0
votes
0answers
15 views

posts_per_page not returning correct number of posts

$queryArgs = array( 'post_type' => 'recipe', //'orderby' => 'menu_order', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 10, // 'posts_per_page' => -1 ); ...
0
votes
1answer
18 views

WP_query problem -spurious results

What am I missing? <? //Specialities Query $args = array( 'post_type' => 'page', 'post__in' => array(24, 26, 28), ) ; $specialities_query = new WP_Query( $args ); // The Loop ...
0
votes
0answers
22 views

Query post from existing category with shortcode

i have created a shortcode to query service item. when i tried to query from category. its not working. i just tried to query post from News category [as-service sitem="4" cat="News"] ...
1
vote
1answer
39 views

Meta Query relation “AND” then set array accordingly

I have a search form on my home page that sets up the url query_string accordingly for the code below. When I use or I get results. However when I used "AND" for the relation I dont get any results ...
0
votes
1answer
17 views

Add posts to WP Query object

I need to filter the WP_Query object by adding some posts to it. I have the posts id's (from another SQL query). What would be the way to add (merge) new posts into the WP_Query object?
1
vote
1answer
29 views

Splice together 2 WP_Query objects

I have been trying for a few days to make a homepage that displays all my posts, and after every 2 posts, a testimonial. I have found dozens of articles describing how to count while you are in the ...
0
votes
1answer
28 views

Different number of posts showing in development vs production server

So I'm working on a website for a client. Everything works fine except for the fact that the number of posts showing in the homepage of my development server is different from the number of posts ...
0
votes
0answers
24 views

category__and works, but why?

I've already found a solution for my question/query but I can't help feeling dirty; this works, but I don't know why, or if there is a better solution. I have a post that has several categories, for ...
0
votes
1answer
35 views

Query to get data of a post, if in category?

You would think you could use $query = new WP_Query(array( 'p' => $idofpost, 'cat' => $numbers )); to return the post if it is a certain category (or categories, or -number to exclude ...
3
votes
1answer
50 views

What is the most efficient way of querying posts based on visits and date for current day?

I am about to develop a piece of code for my site to display the most popular posts of the day that are X days old. I would like some help from you to achieve this the most efficient way. This is ...
0
votes
0answers
24 views

Multi WP Query Problem

im using seprate multi wp query loop but first query cant return my values . anyone can help me ? $first_product = $_GET['first-product']; global $post,$wp_query; ...
0
votes
2answers
36 views

Taxonomy related query not working

For all of my pages I have setup a taxonomy field using the plugin Advanced Custom Fields, for which I can then select as Home category, or something else like News. I am using the default category ...
3
votes
1answer
54 views

compare meta_query in get_posts arguments

I like to exclude certain posts with a custom field. So if my_custom_field_ignore isset AND 1 ignore this post. If it's not set include it. This is what I have $args = array( 'post_type' ...
-3
votes
0answers
10 views

Blog/home does not appear on nav bar [closed]

I installed Thesis theme and now I can't see home/blog in the nav bar. The blog is visible as it is the default landing page but once navigated away there is no way back except by using the back ...
0
votes
1answer
25 views

Get query results with a page title

I want access to an item details by WP_Query with page title I tried this codes but failed: <form method="GET" action=""> <div> <input type="text" name="product"> ...
0
votes
0answers
25 views

Paginate User Query

I am trying to write a simple shortcode function that will return a list of users based on a given meta value. It functions fine, but I am trying to paginate the list. Here is my code: function ...
0
votes
1answer
32 views

How do I add an item to the WP admin menu?

I want to add an item to my WordPress admin menu - "News" - it's to contain a list of articles written about my company. Each article will consist of the following metadata: Headline Date Link to ...
0
votes
0answers
21 views

Order posts by custom field

I have 2 types of posts - event and news. For event category, I have a custom field - event_date while news does not have that field. I want to order the posts according to the event_date. I want to ...
0
votes
0answers
17 views

Sorting posts with a custom algorithm

What is the best way to be able to sort posts in WP_Query by an algorithm, such as: (total votes) * (1 / hours since submission)
0
votes
1answer
16 views

Issue with WP_Query (need a array of selected ID's)

Today I have <?php $loop = new WP_Query( array( 'post_type' => 'inspirations', 'posts_per_page' => 50 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> ...
2
votes
1answer
81 views

Custom query - alternate posts by category

I have a custom post type called "services" with a custom taxonomy called "location". Each post is categorized as either "Location A" or "Location B". I need to query all posts from the "services" ...
0
votes
0answers
16 views

Use meta to match date in WP_Query

I have some posts with a custom filed named "event_end_date". I am using Advanced custom fields for that. How can I get the posts which have end_date older than today? I was trying with this, but ...
0
votes
2answers
34 views

Get posts by category name

I'm having a terrible time trying to figure this out. I've registered a custom taxonomy (clinical-programs) and like to list all the PAGES that are assigned to particular page(s).
0
votes
1answer
25 views

query multiple taxonomies

I have a function set up to show 'Similar Products', i.e. showing products that share the same products-category taxonomy term. This works great but I want to narrow the function even further and make ...
0
votes
1answer
26 views

Get post thumbnail in WP_Query

I wrote an Ajax suggest plugin and I want to get the post thumbnail, but don't know how. This is my plugin code: $s = trim( stripslashes( $_GET['q'] ) ); $query_args = apply_filters( ...
-4
votes
0answers
15 views

how to get subcategory with related post

i want when click a category in index,print subcategory with related post like (w3schools) in category but do not know do this, please help me.