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

How to get specific string in explode array?

I have a shortcode where I'm trying to get a specific string from the $args array below. Query: $args = array( //'post_type' => $posttype, 'post_type' => explode( ', ', $posttype ), ); ...
5
votes
2answers
500 views

Use REGEXP in WP_Query meta_query key

I know I can use REGEXP in WP_Query like this: $query = new WP_Query(array( 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array( array( ...
0
votes
1answer
70 views

The pagination on index.php doesn't work on a first page

I have index.php with a pagination. The permalink settings is plain permalinks. I have a correct pagination view when I open a page '/?paged=2' but if I open just index.php I have all posts without ...
0
votes
0answers
20 views

Convert $wpdb to WP_Query()

I have the code below which I would like to change into a WP_Query so that I can easily filter posts by taxonomies. I am having trouble understanding how I would add get_posts_by_author_sql( ...
0
votes
1answer
28 views

Moving the array pointer inside a WP_Query while loop

How can I move the pointer ahead a place, or at least offset it, as I'm trying to pull two posts during each loop of the while loop? I've indicated where in the loop I would like to move the pointer: ...
1
vote
0answers
20 views

meta_query not working as expected

I have 3 posts that each have two meta values. The first meta value is one that they all share (ac_parent_event). The second is one that is unique to that post (ac_thischild_date). For this function, ...
0
votes
0answers
13 views

Search Post Types and the Meta Boxes

I have meta box called (orginalday), This i will save the post day when the user write post and save it in (pending), And i have form that have 2 input type to search post from day to day. So i need ...
1
vote
1answer
532 views

WP_Query not retrieving by random order under parent

I currently have TWO subpages under parent page ID 43. Client testimonials.. Anyway. I have the random order thing in the query $args but the order never changes. What could I be missing? ...
0
votes
1answer
2k views

forming WP_Query for posts of all post types but from specific categories

I need to get post from blog, custom post type 1, custom post type 2. custom post type 3 and either from category 1 or category 2 or category 3 or category 4 or category 5 or category 6 or category 7 ...
0
votes
0answers
13 views

Query Search Not Working for Users

When I search for a User by their first name, all of their posts show up in the dashboard. When I search for that same User and add their last name, it does not show up at all. Not sure why this is ...
0
votes
2answers
26 views

Get Category Archive Template Name Dynamically

I'm making a category archive template that works for all my categories. I need to dynamically set the 'category' parameter of WP_Query inside of this template to make it work. How do I dynamically ...
0
votes
1answer
19 views

custom page with post content using read more

I have a code for a custom page i'm creating that I want to have my own blog archive (formatted customized) this is my code: <?php ...
0
votes
0answers
21 views

Blog only showing one post even though more published

Why is my wordpress blog.php only showing one blog entry while I have two entrys in the blog at present and have checked both are published and they are and yes i do have my reading setup to my blog ...
1
vote
3answers
504 views

Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”

I am trying to display 3 post_thumbnails from a custom post type "portfolio" on my homepage template. So one from post 'A' , one from post 'B' and one from post 'C' The image from post A will be set ...
-3
votes
2answers
33 views

Undefined variable [closed]

I have created a shortcode for a custom post type query but when I add meta_query values to it, it throws an error: Notice: Undefined variable: my in ...
0
votes
0answers
49 views

Infinite scroll only works on Default Permalink

I have a custom post type list that I display on a page template. There are a lot so I decided to put infinite loading. After changing different queries, I at last made it work but only if the ...
1
vote
1answer
667 views

ACF Relationship Field Search Filtering

I am trying to assign relate posts using the ACF relationship field. It has typeahead search to search by post titles. I would like to add meta_data search to the ACF relationship search. This ...
0
votes
1answer
25 views

Keeping the previous get value and add another value when submitted

I'm a super noob, so I'll try my best to explain. I have a blog page that I wanted filtered by category and I want the user to able to click on multiple categories and it will filter to show those ...
1
vote
1answer
40 views

WP_Query arguments to fetch custom post type posts which are in certain category?

I've played around for hours but still can't wrap my head around the right arguments for a secondary WP_Query which shall fetch all posts of my_custom_post_type that are in the queried category. ...
4
votes
4answers
8k views

Pagination with custom SQL query

I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working ...
0
votes
1answer
40 views

wpdb get_results() returns only 2 rows

I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global ...
2
votes
2answers
9k views

Grab 5 latest posts from custom post type 'announcements'

I have a custom post type announcements which obviously holds posts with weekly announcements. In my theme's header, I want to create a box which has the following semantics: <div ...
0
votes
0answers
11 views

WPML: Custom query looping through languages & putting out one post each round

For a current project I use WPML to distinguish between languages and to manage authors/editors and what they are allowed to write and translate. While there are different language versions of the ...
0
votes
2answers
25 views

Link Author URL's based on a custom field

I'm querying a custom field of users based on a city they are in. I am able to display their profile photo and display name, however I can't seem to get the link to their actual author url to work. ...
0
votes
0answers
24 views

Keeping checkboxes checked WP_query

I have wp_query that allows the end user to filter the query using checkboxes. This works fine until pagination, all the user checked checkboxes get cleared on page 2 how do I get checkboxes to carry ...
1
vote
1answer
114 views

Secondary loop pagination on custom post type single post gets redirected to first page

I would like to output related posts on a custom post-type single page. Everything seems to be set up correctly. When I hover over my pagination links I see ...
0
votes
0answers
19 views

Filter by custom field - dropdown POST not working

I have a custom field "carbz" which has a number value. I am trying to give users a dropdown to select a number and then filter my posts based on the user's input. The current result is returning all ...
0
votes
2answers
30 views

Select posts wich has no relationship in custom taxonomy

I can select posts via my custom taxonomy as explained in the codex. But I am not sure, how I have to set up the tax_query if I want to get only posts which have no relation in the custom taxonomy at ...
0
votes
1answer
52 views

Check for the main query from the template

Besides the main loop in index.php, I'm calling several other custom queries across the theme, like this: $new_query = new WP_Query(array( // some args )); if ($new_query->have_posts()) : ...
3
votes
1answer
102 views

SQL Statement generated by WP_Query not producing expected results

I am trying to alter WP_Query on the pre_get_posts action hook, for filtering the posts returned, depending on the built-in category and post_tag taxonomies. I would like that the only posts returned ...
0
votes
1answer
20 views

Duplicates When using Nested WP_Query

I think I'm missing something really simple but I'm at my wits end and hoping to be pointed in the right direction. A little background. I'm working on a site for a creative agency. I'm using ...
1
vote
1answer
25 views

Multiple Loops Inside a Function

What I understand from the CODEX, (https://codex.wordpress.org/Class_Reference/WP_Query#Multiple_Loops). then I'm trying to do a list of posts like this: <nav id="cbp-hrmenu" class="cbp-hrmenu ...
0
votes
2answers
438 views

Hide Administrators From User List except current user (administrator)

this code works great! the problem is that this code also hide the current user (if administrator) so what i trying to to do is hide all Administrators except current user. i need help to edit sql to ...
0
votes
1answer
525 views

Single post - display list of all posts + specific post

I want to display on single post three things: List of all posts in general Single post title Content What I achieved right now is not satisfying because I am displaying all posts (and it works ...
1
vote
1answer
39 views

Order posts by meta value and Date

I'm trying to sort posts based on one post meta value and date. I'm using this plugin ( https://github.com/JonMasterson/WordPress-Post-Like-System ) to add like system to my posts. The code that ...
1
vote
2answers
40 views

Display certain amount of posts on taxonomy archive page

I have a taxonomy archive page where I display everything under the term 'techno' I want to be able to limit this to 20 posts to a page until it paginates. At the moment it displays 10 on one page and ...
0
votes
1answer
35 views

WP_Query get post from a category and from another post type

I have 2 post types (post and help). In post (post type), there is a category named "Hello" and I want to get all posts from the category "Hello" (post_type = post and category_id = 2) and all posts ...
0
votes
1answer
226 views

Added Date Filter To Popular Posts Query

I have the following query, which was put together with snippets in the functions.php file: <?php $popularpost = new WP_Query( array( 'posts_per_page' => 5, 'meta_key' => ...
1
vote
0answers
29 views

ajax category filter

I know this is a big ask for you guys, but i can't seem to figure this out. I found this page : http://www.bobz.co/ajax-filter-posts-tag/#comment-28112 it shows how to make a dynamic filter for post ...
0
votes
1answer
153 views

WP_Query custom field pass the post id

I'm using WP_Query with ACF(Advanced Custom Fields) I'm building a news portal, and I'm trying to pass related stories from 1 post which is top_story = true. In another WP_Query I want to print the ...
1
vote
2answers
54 views

How to limit WP_Query to one result on the loop?

I am trying to get only one post and this needs to be the latest one so here is what I am doing: $basic_args = $wp_query->query_vars; $basic_args['tax_query'] = $wp_query->tax_query; ...
1
vote
1answer
24 views

Get a post from other loop each n-posts in the main loop

Here's the layout, I'd like to achieve. 1st row: three posts in three columns from category A 2nd row: one fullwidth post from category B 3rd row: the next three posts from category A 4th row: ...
0
votes
2answers
640 views

Custom search: Search posts but display parent page in results

I'm using Wordpress 3.5.1 with a modified twentytwelve theme. My main site structure is based on the Smooth Slider plugin (jQuery Cycle). I have Pages that contain only a shortcode (for example, ...
0
votes
2answers
45 views

Transients with dynamic WP_Query

I have a <form> with about 20 inputs (mostly select and number) which each is an argument in WP_Query if filled. I learned today that I could use transients to store results which seems like a ...
4
votes
1answer
65 views

WP_Query - filter or directly?

The count of my files, templates, scripts, queries etc is getting big and I need a good system to maintain it all. I've tried to keep everything organized: No <script> tags in templates ...
0
votes
1answer
65 views

Archive for custom taxonomy lists all posts instead of current taxonomy

I'm using the Types plugin for a custom post type "Session", which has the custom taxonomy "Semester". I would now like to create an archive page for each semester which is automatically generated. ...
-1
votes
1answer
30 views

How to create a loop inside WP_Query?

I want print array in a loop and want to put it inside WP_Query. Is it Possible? If there are other alternatives kindly mention it. $wp_user_query = new WP_User_Query(array('role' => ...
0
votes
1answer
58 views

Display List Of Posts Containing a Relationship Field Value [ACF]

I have a post type called 'Writers' and another post type called 'Documents'. I use the Relationship field in Advanced Custom Fields to link a list of Writers (post objects) to a Document. This means ...
-1
votes
1answer
29 views

how to show only catergory titles on a page in wordpress

How do you show category titles on a page in wordpress. I want to to show the category titles on my home page which would then link to the first post in that category. I also want to show the image of ...
1
vote
1answer
499 views

Site not getting correct featured image from my query

On the home page of my site I have a series of tiles that link to various parts of the site. One tile links to the blog and I have written some code to pull the latest post with an image attached to ...