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

Wildcard search in WP Query

I am trying to do something like this: $args = array( 'post_type' => 'product', 'meta_query' => array( array( 'key' => 'custom-text-field', 'value' => '%rocket%', ...
0
votes
1answer
36 views

Custom Taxonomy with Custom Post Type Finds No Posts

I've created a custom post type named mfg_ppn and a custom taxonomy called mfg_pp, and they are referenced as $this->cpt_promotion_newsand $this->cpt_promotionin case you were wondering about ...
0
votes
0answers
9 views

Pagination on custom post type with 2 wp_queries [duplicate]

Im trying to get my pagination on a page that lists all custom post types working. I have tried both the bones theme next/prev as well as the default wordpress option, to no avail. This is the two ...
0
votes
2answers
54 views

How to query for posts (in hierarchical custom post type) that have children?

I'm trying to figure out how to query for posts in my hierarchical custom post type, presumably using WP_Query that have child posts. I can get all pages that don't have children by setting ...
0
votes
0answers
34 views

meta_query compare not working

I'm trying to run this WP_Query on tag.php, and it doesn't seem to work. $tag = get_query_var('tag'); $args = array ( 'tag' => $tag, ...
0
votes
1answer
34 views

Get custom posts with certain ids in a custom loop using a shortcode

So I'm using custom loop and shortcode to insert it in any page. Like this: function register_custom_shortcode($atts){ extract(shortcode_atts(array( 'ids' => '', // this is what I ...
12
votes
5answers
5k views

How to extend WP_Query to include custom table in query?

I have been days over this issue now. Initially it was, how to store a user's follower data in database, for which I got couple of nice recommendations here at WordPress Answers. After, following the ...
7
votes
4answers
279 views

How to merge two queries together

I am trying to order the posts in a category by showing the posts with images first and then posts without images last. I have managed to do that by running two queries and now I want to merge the two ...
0
votes
2answers
40 views

Order by multiple meta keys on wordpress

After multiple research I didn't find the correct answer to my question. I just need to order my custom post type by date and then by time (format: 18:00). Here's what I tried: ...
0
votes
0answers
59 views

Course listing with multiple dates

I'm trying to build a course listing (custom post type) - each course has multiple dates assigned to it, but I'm failing miserably (mainly due to my poor PHP skills!). I'm trying to use standard ...
0
votes
3answers
429 views

shortcode using multiple WP_Query's with multiple category names not fully functional

we're working on a bilingual site, Larry A. Downs all the posts are categorized into two categories, english or spanish, along with other categories. so every post has multiple categories, i've ...
0
votes
0answers
28 views

Wordpress query vars are not added

I'm currently trying to figure out how to get my custom url rewrites working (WP Rewrite the last two parts of the URL), while doing this I came across the following problem: I have made a custom ...
2
votes
2answers
82 views

How can i get the last post from wp multisite?

I have to get the last post from my Multisite network on WordPress. For now I use this code for display the last updated post after a cycle on each blog_id: <?php $blogs = get_last_updated(' ', ...
0
votes
1answer
33 views

Does query_posts have an effect on get_the_category?

I am having trouble debugging a situation, and I think some better background information on how these systems work would be very helpful. I know that the use of the function query_posts is strongly ...
0
votes
0answers
23 views

Sort posts in dashboard using custom field; also include posts where field isn't set

I'm using a pre_get_posts filter found on this question thread here, to sort a custom post type in the dashboard: function xyz_event_sort_order( $wp_query ) { if ( is_admin() ) { ...
0
votes
1answer
53 views

Show custom post type filtered by category

I would like to have a custom post type which contain several sliders for showing in each category page (exact category.php), one for each as planned. All sliders were assigned to related category. ...
0
votes
1answer
57 views

Merge 2 args in one WP_Query and order it by date

I'm trying to merge 2 WP_Query in a new WP_Query and then order all posts in this new merged query by date descending. I can merge 2 WP_Query and work fine, but I can't order the new query $args1 ...
0
votes
0answers
35 views

Orderby custom date fields with meta_query broken on OR relation

I have an 'event' post type that has custom start and end date fields. In a block on the home page, I'm trying to show only upcoming or ongoing events. So, to achieve this, I'm doing a meta_query that ...
0
votes
1answer
39 views

Passing conditional arrays to WP_Query() [closed]

I've looked around at a few places and could not find an answer. I was wondering what the best way to create a WP_query from possibly empty variables were. I have about 16 of these $_GET variables. ...
0
votes
1answer
44 views

Second loop pagination changes URL, not content

I'm reasonably new to WordPress and I believe I am missing something conceptual here. I have assigned a static post to be my front page. My front-page.php template begins with a standard loop: ...
0
votes
0answers
35 views

How to add archives (with pagination) to page template?

So the site I'm building has a few different archives pages. For the newest one I'm building, I tried to copy the archive.php I've got: page-archives.php: <?php get_header(); ?> <section ...
7
votes
4answers
4k views

Broken? WP_Query and “attachment” as a post type

I have a gallery attached to a page. On that page, I'm running the following query: $events_gallery = new WP_Query( // Start a new query for our videos array( 'post_parent' => $post->ID, // ...
0
votes
1answer
49 views

Displaying content to search engines but via navigation only for registered users.

Displaying certain information depending on if a user is registered is quite easy as I have been using this code <?php if (current_user_can(‘subscriber’)) { ?> [content here] <?php } ...
0
votes
0answers
21 views

how a query can use local parameters in plugin function?

I've wanted to add a custom post type, so i've done a plugin to put on/off this post type. i have widgets inside the plugin in order to print posts with this custom type, that call more or less a ...
0
votes
2answers
54 views

WP_Query of Category Not Showing First Post

I have the following loop, and only this loop, in my home.php file (apologies if I didn't paste the code properly). I have populated lorem ipsum posts, and noticed that of the five posts only four ...
0
votes
0answers
33 views

Custom WP_Query with SQL directives for getting posts by authors and terms

I am making a custom page where I need to display posts from authors and terms (categories). I tried with the built in WP_query arguments but I am not getting the result I want. So I want to know how ...
0
votes
3answers
107 views

ACF: post query, hide duplicate values

I'm querying an ACF field, and displaying all the results on the front-end like so— PHP: <ul class="category-menu-items"> <?php // args ...
0
votes
0answers
22 views

What is the best way and how do I display posts from categories and users a user is following?

I am making a user/term following system where users can follow users and terms (inlcuding categories). Once the user follows another user and/or term I am saving the ids for each in a custom table. ...
0
votes
1answer
52 views

Randomly select one of last 3 posts

ok so i have this: $args=array( 'orderby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 1, 'offset' => $offset, ); $q = new ...
0
votes
0answers
26 views

Trying to do a custom Search results page. Failing when I use the pagination

I'm trying to do a page where the user can search for posts with a Keyword (as search.php) and post date filter (between one date and another). I have a form with 3 fields: keyword, date1 and date2 ...
-1
votes
1answer
160 views

How to query posts from specific authors and categories using WP_query?

I currently have a WP_query where I am getting posts from a specific set of authors. To this, I want to add specific categories as well. $args = array( 'author__in' => $authors, 'posts_per_page' ...
0
votes
0answers
26 views

Post OrderBy slow performance

I have been struggling for quite a while now with this, to put in simple term here is what i do. I do an OrderBy with wp_postmeta information This allow me to give an additional date to play with. ...
0
votes
0answers
23 views

Query custom post type by date field only working when two posts match the query

Hi I am trying to query a custom post by an advanced custom field that is a date field and this is how it is registered in a plugin that I have created to take care of all non-visual aspects of the ...
0
votes
1answer
21 views

How can I pull information from my loop and divide them seperately?

I've created a Custom Post Type that I'm trying to implement into a CSS slider. To do this I've created a custom template and added counters to get unique ID's for every new post that get's pulled. ...
0
votes
0answers
49 views

Pagination for blog posts reloading same page

Symptoms Visiting /blog/ loads the first 10 posts, as expected. Visiting /blog/page/2/ (and onward) loads the new URL but with the same 10 posts. Nothing changes but the URL. Setup Details Custom ...
0
votes
0answers
20 views

how i can make recursive wp_query and work

What i have done so far is: on single post page i have a box with 3 recent posts, i use WP_Query and reset with wp_reset_postdata(); i have made a shortcode that displays recent posts, i use ...
0
votes
0answers
11 views

WP_Query & posts_per_page [duplicate]

I have created a custom loop with WP_Query and I am trying to display only 4 posts. I do not need pagination or anything similar. Just the four posts. I am using posts_per_page => 4 to do this, but ...
0
votes
2answers
51 views

Order posts with custom taxonomy array

I am trying to make my loop go through the posts that are associated with these terms. Currently nothing is being output. <?php $args = array( 'post_type' => 'staff', ...
1
vote
0answers
30 views

echo a specific meta_key queried through a custom post

I'm new to coding but love tinkering around (on Virtual Server) with bits to upgrade my current website when I have the time. What would be really useful to me would be to post an individual ...
0
votes
2answers
44 views

How to get Tags with specific post id

I have created one post and post ID is 34 and added some Tags and Now I want to retrieve all tags with post ID. Any Idea?
0
votes
0answers
53 views

Filter plugin posts by meta value

I am a WordPress beginner, but have a few years of software development experience. I have a WordPress plugin used to display custom data via a custom post type. The index page contains something ...
4
votes
1answer
91 views

How do you get the count of posts in an archive page?

I have a custom posts archive page of the type archive-my_custom_post_type.php and I am using the "standard" loop which consists of the ever-so famous <?php if(have_posts()) : ?> <?php ...
0
votes
1answer
59 views

Custom post type blog pagination conflict

I have a custom post type called 'emp_case-studies' and it has a page archive. Here is the code for archive-emp_case-studies.php: <?php $blog = $wp_query; $wp_query= null; $args= null; ...
2
votes
1answer
119 views

How to make a WP_Query search with custom post types?

I've registered a custom post type called "node". When I create a basic WP_Query to get posts of that type, it works just fine. Example: $args = array( 'post_status' => 'publish', 'post_type' ...
0
votes
1answer
33 views

query post based on comparison

Each post in my site can be rated as 'good' , 'ok' , 'bad'. The values are stored in custom fields. I now need to show top 10 posts with maximum 'good' and it should not display posts with greater ...
0
votes
1answer
105 views

Display count number of posts with the same specific meta_key meta_value

I want to display a list of posts ordered by a specific meta_key. My posts have the following custom fields: author_lastname and author_firstname. So far, it works good. The posts are displayed ...
0
votes
0answers
15 views

How to get from a query an array of post names of a particular custom post type? [duplicate]

I need to get an array of post names (not titles) of a particular custom post type from a query. How to do this? My query: $query = new WP_Query( array( 'post_type' => 'fpps', 'post_status' => ...
0
votes
2answers
150 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
87 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
0answers
12 views

Get posts from similar time as current post

Hi guys I've been struggling with this for a while and wondered how you lovely people would go about implementing it. I would like to show 4 posts that were posted before and after the current post. ...