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

wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query

I'm implementing a form for a frontend post with a shortcode. The form is processed in the same function, reloading the page: function adicionar_ninhada(){ $user_id = get_current_user_id(); if ...
1
vote
1answer
22 views

How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()

I'm using the code from miguelpeixe's 'WordPress Query Multisite' in order to create a custom loop for my WP Multi-site's 'child sites.' Within this loop, I want to nest another loop that will pull ...
0
votes
1answer
37 views

Meta Query with date and time on the same Day before given time

I have a metaquery for a custom post type "events". Their start date is stored as a meta field in this format: 2016-02-05 19:00:00 These are my query args: $args = array( "posts_per_page" ...
0
votes
2answers
32 views

Advanced WP_Query with meta_query, orderby?

I wonder if anyone can help me with this little complex query with ACF. I have the following so far which should display: Pages, News Articles, About Articles and Involved Articles. Show: only ...
-1
votes
0answers
27 views

$wp_query filters with html input

I am stuck in add filters to $wp_query with inputs from html. Like when user enters a string in input box & the query is filtered with each letter. Any suggestion will be appreciated. Scenario ...
1
vote
2answers
60 views

new WP_Query() - what is the earliest valid hook?

Specifically, is it valid to run a new WP_Query() during the plugins_loaded action?
1
vote
0answers
15 views

Random ajax load only works with posts_per_page set to -1

I created a post loader shortcode, that uses AJAX to load posts. Even though I can set the order and order_by query parameters, the order_by should be random. From what I've seen on the web, ajax load ...
1
vote
2answers
37 views

WP_query to get the first two latest posts, then another loop to get the next three

My ultimate goal is to list the latest 5 posts, regardless of category. I would first like to make a WP_Query to get the latest two posts and insert them in to a specific HTML structure. Then I ...
1
vote
2answers
36 views

Clean up WordPress code that repeats

I want to use the following code multiple times in the same page template, however the template gets too big when it comes to lines of code and therefore size. Every time I use it I change only one ...
1
vote
0answers
21 views

Array Chunks and Inserting Varying HTML in WP_Query

I am trying to output the latest 5 posts from my blog. I would like each post thumbnail to populate divs in the following format. <div class="row full"> <div class="large-6 medium-6 ...
0
votes
1answer
19 views

WP_Query arguments relation shows AND instead of OR

In wp_postmeta I have a meta_key which stores colon separated strings such as "CA:Georgia:NY". So for meta_key='state' there can be several entries like: For post 1 = "CA:Georgia:NY' For post 2 = ...
1
vote
0answers
22 views

Exclude Category filter from Portfolio section

I am stuck with this since hours and found lots of forum entries about NOT IN, WP_Query, category__not_in portfolio, editing JS/ CSS in Theme options or having bits of code to add to portfolio.php, ...
5
votes
1answer
54 views

How does reset_postdata restore the post of the main query loop?

How does reset_postdata works? The docs say: restore the global $post variable of the main query loop after a secondary query loop using new WP_Query But in the class, it takes the "current" ...
-1
votes
1answer
15 views

Where to find WP_Query class?

I cannot find WP_Query() in my wordpress folder, the global refers to $wp_query but I don't find the class itself. From my wordpress folder, or here directly : ...
1
vote
0answers
16 views

Custom Taxonomy and tax_query Issue?

I am working on Plugin development and my plugin name is plugindev.I have a custom post type called team.I have a custom taxonomy Team_Category which is being registered by this code ...
1
vote
0answers
17 views

Prioritize posts in query by meta keys?

I have a CPT called jobs. In my single jobs page I am counting page views with these functions: /********* Post Views counter ***********/ remove_action( 'wp_head', ...
0
votes
1answer
14 views

How to order by datediff in WP loop?

I have a custom post type for events with a custom field named event_start_date, and I want to sort the archive loop according to the nearest event_start_date. In other words, the event with the ...
1
vote
1answer
32 views

WP Query with custom Shortcode

I have the following in my functions.php:- /** * Shortcode: Latest Properties */ function latest_properties_func( $atts ) { $args = array( 'posts_per_page'=> 5, 'post_type' ...
0
votes
1answer
26 views

Query with two posttypes and two different meta_keys

I need to query two custom post types, like this: 'post_type' => array ('single_events', 'group_of_events'), and i need to select certain posts in a certain order, to do this i wrote a meta ...
2
votes
4answers
68 views

Trim first 2 words of the exceprt

I am currently pulling in the post excerpt however there are 2 words at the start of it that I would rather not have in this particular place as there is a title already. I have used wp_trim ...
1
vote
0answers
17 views

Lists Posts from CPT that match the Title of the Page

I am trying to get all the posts associated with the Title of a page. This is what I currently have: <?php $title_to_tag_posts_query = new WP_Query( array( 'tag' => ...
1
vote
0answers
8 views

auto-populating custom nav with all items from custom post type

I have written the following code to take all of the posts in my custom post type "products" (created with ACF) and inject them each as an <li> in a custom nav menu. Everything is working ...
1
vote
0answers
21 views

get product title ID and price and product picture woocommerce by cat-id query select mysql

i have query that return categories in woo-commerce like this: SELECT wp_terms.term_id AS id, name FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id WHERE ...
0
votes
0answers
18 views

Custom query for tag and custom tag from 2 post type

I have custom post type called items and added custom taxonomies type and sub-type. I like to query posts from both post and items post type that has art as either Tags or Sub type. Below is what ...
2
votes
0answers
10 views

Generate a tabbed submenu — from taxonomy term or submenu item — with sample content

I'm looking to generate a tabbed submenu from taxonomy term or submenu item and include sample content (three items per term/submenuu item). The styling I can do, the problem is the html generation. ...
1
vote
1answer
16 views

Get posts from WP_Query and format them on admin_head

I am trying to prepare an array with Custom Post Type posts to populate a select options in TinyMCE. I was thinking to fetch posts, get their IDs and titles and put them all inside $data variable, ...
0
votes
1answer
20 views

Wp query show post by author name or post title or post content

I have to create a search query which allows me to filter all posts where author name and post titles or post content has the word from search textbox. So if i search wordpress it should list all the ...
0
votes
1answer
19 views

query_vars empty when using custom url with custom rewrite rule

I'm trying to pass custom url parameters to pretty urls using add_rewrite_tag('%product%', '([0-9/]+)'); ...
5
votes
2answers
73 views

How to list some posts first in the loop based on post id

I have a query for to display some posts . $args = array( 'post_type' =>'products' 'posts_per_page'=> 12, 'orderby' => 'meta_value_num', 'meta_key' => '_price', ...
-1
votes
1answer
35 views

Standard Loop - wp_query

I was readind this article (https://codex.wordpress.org/Class_Reference/WP_Query) and try run the Standard Loop, but I can't receive the any result. My code is this: <?php get_header(); /* ...
1
vote
1answer
24 views

Sort by meta key on archive page

I am trying to sort an archive page using a meta key value (which happens to be a Unix timestamp). Currently I have the posts listed on the page by their WordPress creation date. I want to use the ...
1
vote
0answers
24 views

Search form not working with custom query?

My search query doesn't seem to work, the query in my url is all correct but the content just refreshes without finding the posts with the search term.. I got a custom search query and a function to ...
0
votes
0answers
16 views

Lazy loading Ajax offset not working

I am attempting to create a lazy loading ajax feature on my site. There is a 'click more' button which will then load 10 posts via ajax and append them to the HTML container. I want to display 10 ...
0
votes
0answers
15 views

query order by a function

I was wondering how to order posts by a function that returns a number. I've set up a query and i want to order my post by that number. Here is what I have: $foo = get_like_count(); and in the ...
2
votes
1answer
35 views

A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value

I'm looking for a way to basically have an OR relationship between the date_query and the meta_query. Basically I want to combine the two WP_Query's. Get the posts from the last two weeks $args = ...
0
votes
0answers
18 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
0answers
32 views

How to pass multiple page ids from a custom field variable into post__in wp_query

I have a client that wants to pull content from multiple pages using page_ids listed in a custom field (363, 87, 95) without interfering with the main loop content (can't use sub-pages as same page ...
1
vote
0answers
18 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
1answer
27 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: ...
0
votes
0answers
10 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 ...
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
25 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
18 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 ...
-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 ...
1
vote
1answer
37 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. ...
0
votes
1answer
37 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 ...
0
votes
1answer
30 views

wp_delete_post deletes all posts instead of just expired ones

I am trying to set up a cron job which deletes posts which have past their expiry date (i.e expiry date < today's date). I have a meta box on the custom post type which adds an expiry date to the ...
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 ...
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 ...