"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
2answers
57 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
27 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
44 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
27 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
1answer
54 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
33 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
21 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
23 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
25 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
21 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
15 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
30 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
63 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
41 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
20 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
19 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
24 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
2answers
57 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
22 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
34 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
31 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
28 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
37 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 ...
4
votes
1answer
70 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
26 views

Multi WP Query Problem [closed]

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
39 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 ...
4
votes
1answer
84 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' ...
0
votes
1answer
28 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
42 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
32 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
20 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
18 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
110 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
19 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
53 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
32 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
52 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( ...
0
votes
1answer
75 views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
0
votes
1answer
38 views

Get posts with no tags?

I have over 1000 posts with no tags. Basically I am trying to get posts with no tags to show in frontend so that users can add tags from frontend. I am using this approach in loop so as to show posts ...
9
votes
1answer
106 views

Should we trust the post globals

@toscho left a comment to this answer which had me thinking again. How much trust should he have in the global scope, specially regarding the post globals like $post. So what? The global variable ...
0
votes
0answers
9 views

AJAX Returns an error when deleting post

I would like to delete the post using wp_delete_post via AJAX however while wp_trash_post works beautifully, the wp_delete_post returns an AJAX error. I used WP_Query to delete the post that is in ...
0
votes
0answers
15 views

Modified query_string has stopped working in WP4

The code blow was used to load a filtered taxonomy archive and worked fine up until the release of WordPress 4.0. Since upgrading to 4.0, it's not returning any results. Any ideas what might have ...
0
votes
0answers
47 views

query and paginate multiple post types

I'm looking to query multiple post types and paginate them so the results are across multiple pages. The markup I have is as follows: <?php query_posts( array( 'posts_per_page' => 100, ...
0
votes
1answer
36 views

Multiple meta query from array

I need to do multiple meta query from my array. I have something like this: $search_term[] = array( 'key' => '_cmb_listing_status', 'value' => 'Active', 'compare' => '=' ); foreach ( ...
0
votes
0answers
16 views

Help : how to Display only 3 random post from the most recent 100 in 120 days

that's my code : $args=array('post__not_in' => array($post->ID),'posts_per_page' => $related_no, 'orderby' => 'meta_value_num' , 'meta_key' => 'tie_views', 'post_status' => ...
0
votes
1answer
60 views

Avoid duplicate while merging two query post

I have merged two query post, but when I fetch their results, it shows duplicates. Here is the code $arg = array('post_type' => 'story','post_status' => 'publish', 'orderby' => 'date', ...
0
votes
1answer
25 views

Advanced Post Display/Pagination/Ordering

I am working on a project that requires some advanced ordering of posts and advanced pagination. Basically, we have posts in a category, lets call this category 'mycategory'. We then have post ...
0
votes
1answer
38 views

Order WP_Query results in order other than ASC or DESC

I have pages with a custom field "language" which can be, say, "EN", DE" or "FR". On a category page I want to output them in a specific order, say, first EN pages, then FR pages, then DE pages. It ...
0
votes
0answers
48 views

Meta Compare (EXISTS) does not work

I want to include the posts that have a certain meta_key and exclude those that does not have that meta_key. NOT EXISTS works but EXISTS fails in the code below. function include_meta_key( $wp_query ...