Questions tagged [wp-query]

"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 global variable that holds the main query object prepared by WordPress based on a given request.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

Capture search term, input into 2 searches and output data on 1 page

Apologies if this may seem trivial but, although i've been working with Wordpress for a few years now, i only recently started using slightly more complex code implementations. What i am trying to do ...
0
votes
1answer
58 views

posts_per_page not working in block

I have created a new Block for the Wordpress Editor, and I am trying to get a simple WP_Query to work, but so far, the $args in the query are mostly ignored, apart from the post_type setting. For ...
0
votes
1answer
17 views

Delete post meta by serialized meta value

I have some post meta entries which I like to delete from the database. The delete_post_meta() function seems the way to go: delete_post_meta( int $post_id, string $meta_key, mixed $meta_value = '' ) ...
0
votes
0answers
7 views

Question: How can I retrieve the post details liked by the current_user using the post_id from the “Different” post_type?

I am soo new to Wordpress development, so I am so lost in this. I have a custom post type "Like" that automatically adds the post_id of the page/post the user liked, and the "Like" post type contains ...
0
votes
0answers
9 views

How to add Adsense code in between posts?

I am using the Genesis Framework for my coupon website. I am using the function genesis_custom_loop to create WordPress posts loop. Reference for genesis_custom_loop: https://genesis.community/wiki/...
0
votes
0answers
15 views

CPT next post issue

I'm struggling on this one. I've inherited a project where I need a next post item on a custom post type. However, initially the CPT didn't have an archive. The following code I put in, is inside the ...
0
votes
0answers
9 views

One post per one column item in a row. How to?

I am planing to construct a new responsive website from sratch. Initial plan is at least one row with three columns for index.php (within body tag). What approach would be better to achieve my goal so ...
1
vote
1answer
20 views

How to insert 2 args into 1 Wp_Query for a slideshow

I need to post articles and pages present in two specific taxonomy in a slider. I tried to merge the $args and $args2 but the slider disappears from the page. Could anyone tell me how to write the ...
0
votes
0answers
14 views

Wordpress show limit pages in pagination, in real it has more

I use custom queries in the home page. In dashboard i set 25 posts per page. Number of posts more then 3000. In query I set 25 posts per page. But in home page I get only 17 pages (must be 121). If I ...
1
vote
1answer
15 views

new WP_Query(), have_posts() return false in user_register hook

The $notifications->have_posts() return false, though I'm sure there are few posts of this custom type, in the database. add_action('user_register','jq_after_user_register_hook', 10, 1); function ...
0
votes
1answer
27 views

Searching for a specific month in a metadata saved as Timestamp (Wp_Query)

I need to keep the payment dates for a post type I created called "Payments." For this, I created a meta key called "expected_payment_date". I save the expected payment dates as timestamp. For example,...
0
votes
0answers
22 views

Query ACF repeater subfield

Maybe someone could help me, I used ACF to create a repeater field for some events and I wanted to show only events from today and from the future. The closer I got was with this code "if(strtotime(...
0
votes
0answers
14 views

Display Custom Post Type Based on Taxonomy With WP_Query()

I would like to pull in 3 posts from a custom post type called 'articles' that have a 'Featured' custom taxonomy term. I'm using the code below, but it isn't pulling in just the posts with the '...
0
votes
0answers
13 views

Sorting events by values of date and time from custom fields, when they used to select only past events, goes wrong

I think it works perect to select posts, that 1) date in custom field is less than today 2) if it's today, i check if time is past. But it does not sort them in right order. It's sorted by date, but ...
0
votes
0answers
12 views

Should I use 'tag', 'cat' and 'tax_query' parameters together in a WP_Query?

What I'm building I'm developping a plugin. I'm currently filtering the posts by tags and categories (tag and category_name WP_Query parameters) with values given in a shortcode. I want to add the ...
0
votes
1answer
20 views

Get post and its children with WP_Query

I want the parent post and its children posts. I don't know the parent post ID, only that its post_password field is not empty. It's very similar to this question except the post ID is not known in ...
0
votes
0answers
25 views

WP_Query and Meta Query filter custom post type by capability

I am currently using WP_Query for my custom filter function of a custom post type and I would like to filter this if a user has a capability. Using roles is also an option, but it would be easier if ...
0
votes
0answers
16 views

How to check if logged in user have pending custom post?

I want to show a message to users who have their post pending for approval. I can do it with wp query like below but wondering if there is more efficient way, like a function; something looks like ...
0
votes
1answer
33 views

Shortcode for custom query not returning results when attributes are added

I'm trying to build a shortcode that will allow the user to choose what category is displayed and how many posts will show. The shortcode worked fine until I added the 'tax_query' add_shortcode( '...
0
votes
2answers
25 views

Order by meta_key doesn't work

I am using this code but it seems that ordering by meta_keys br_category first and br_name second, doesn't produce the correct results $args = array( 'post_type' => 'brands', 'meta_query' =&...
0
votes
0answers
17 views

Get taxonomy terms used in posts that have second taxonomy with specific term

I'm not sure I know how to phrase this question best, so please bear with me. I have a custom post type (artworks) which has two custom taxonomies attached (artist eg. name, and media eg. painting ...
0
votes
0answers
12 views

WP_Query Regexp whitespace and end of string

Hello I'm using ACL and I have trouble with REGEXP. I tried many ways but somehow it doesn't work. The meta-field is a ACL-Textarea. I need to search after searchword. After that word there may ...
0
votes
1answer
16 views

can I extend the WP_Query class to deal with 'duplicate' posts created by joining to wp_posts?

Based on the premise that one big database requests is better than many smaller ones, I've modified WP_Query for my custom post type 'word' and joined three tables to it. The resulting query looks ...
0
votes
1answer
18 views

Change normal grids to masonry grids

I'm currently creating a wordpress theme and so far all my code is working fine (my theme is based on the isotope js gallery), but I would like to transform my normal grids into masonry grids, could ...
2
votes
0answers
17 views

What's the point of the query_vars filter?

WordPress doesn't seem to support named parameters in a query string (like ?foo=123&bar=456) unless you explicitly allow them by doing add_filter('query_vars'...). Why is this? What (presumably ...
0
votes
3answers
82 views

Assign meta_query value to php variable

I am using this code for a meta_query $values = shortcode_atts( array('category' => 'Test',), $atts ); $args = array( 'post_type' => 'mytype', 'post_status' => 'publish', '...
1
vote
1answer
12 views

Loading the same WP_Query in two different wordpress .php templates

I'm successfully was able to load this WP_Query to my Wordpress template-full-width-home.php (page One) file: template-full-width-home.php <?php /* Template Name: Full Width (No Sidebar) Homepage ...
0
votes
0answers
21 views

Create Post Query to order by a Taxonomy custom meta field

I have a standard WP_Query to search for Posts of a certain Custom Post Type. I am trying to extend this by filtering by a specific custom meta field that was set for a Taxonomy that is attached to ...
0
votes
0answers
23 views

Variable ++ in query loop

There are 2 dynamic changing requiers thing in my html.they are "active" and "numbers (for example 1,2,3...)".I want write "active" into class if it is first element in query, else write only one ...
0
votes
0answers
21 views

Set ranking number orderby meta_key for specific Posts

I use a custom field totalreviews for rating my products I need to figure out how to get a rank listing like #1 OF 100Posts #25 OF 100Posts and display rank in single.php or homepage I did some ...
0
votes
0answers
17 views

WP_Query() displaying past post / event

I'm making a page for past events (using Event Expresso plugin) and I'm kinda confused about the wp_query. This one works: $atts = array( 'title' => NULL, 'limit' => 100, '...
1
vote
1answer
26 views

Load More Posts Button - AJAX

I'm trying to add Ajax to my theme so I can load my posts dynamically. The following code works but for some reason when I wrap the button that fires the loading with another div it doesn't do ...
0
votes
1answer
16 views

WP Query - Show custom posts only if user contain some user meta

I am trying to make a list of custom post type which going to show all posts but only if author contains custom user meta named "activeacc". So.. I have thic code... $args = array( 'post_type' =&...
-1
votes
0answers
17 views

Pagination with custom query

I can't do work pagination in my theme. I use custom query. <?php get_header(); ?> <main id="site-content" role="main"> <?php $archive_title = ''; $archive_subtitle = '...
0
votes
0answers
14 views

Wordpress pagination links with query args

I have set some arguments to the paginate_links function and managed to do pagination with query args instead of path, but on the first page it does not rewrite my arguments, it just keeps the current ...
0
votes
1answer
20 views

How can I query and sort custom-post type using WP_Query

guys, I have a custom post type called "game" and it has some custom fields (get_post_meta) which I access by their keys "_game_date_key", "_game_home_goals_key" and "_game_away_goals_key". How do ...
0
votes
0answers
12 views

Custom order of posts in wp_query and different taxonomies

Say I have the following: Post IDs: 1,2,3,4,5,6,7,8,9,10 Category: A, B, C, D, E I want to create A page that will contain Taxonomy A and have the following Post IDs in the following order: 4, 6, ...
0
votes
2answers
28 views

order posts by a secondary query that counts items

i'm working on a music plugin. It uses a custom table tracklist_items to store every tracks of a playlist; which has a structure like this : |id| |track_id| |tracklist_id| |order| |time| So if I ...
0
votes
1answer
16 views

Result of Custom WP_Query appears on 404 Page (but result are found!)

I wrote a custom search page. It was working well then I added additional changes, now I got 404-Result-problem. The problem keep there even I did revert (I have backup) and I cleared the cache. I'm ...
0
votes
1answer
14 views

Get posts that match defined arrays of tags

I've been scratching my head a lot and couldn't find a reasonable solution that would not require multiple queries. In my case, the posts have multiple tags, but they can be divided into to "sets" ...
0
votes
0answers
26 views

wp_query with meta_query and tax_query

I am trying to find a way to combine a meta_query and a term_query and i got confused with the research. $sport = 'basket'; $args_p = array( 'posts_per_page' => 10,...
0
votes
1answer
17 views

WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)

This is really confusing me. I've tried numerous things but cannot get appropriate results. Here's what I currently have for my query: $args = array( 'post_type' => 'product', 'tax_query'...
0
votes
1answer
17 views

WordPress live search and filter custom fields

I have the following code intended to fetch, filter and display custom post on input(onkeyup). However, it sin't working at the moment; I also get a 500 (Internal Server Error) when I open the console....
0
votes
0answers
19 views

Pass post ID to JavaScript outside the loop

I try to pass the post/pages ID to my JavaScript file. url and template_url works but the id just return 0 on every post. PHP: // Register scripts wp_enqueue_script('scripts', ...
0
votes
0answers
17 views

WordPress live search and filter

I have a grid of posts on my archive page. How can I filter through them once I start typing on the search bar, or filter by category on click, please?
0
votes
2answers
58 views

wp_query is showing posts from other categories

I am trying to make a custom loop that will display the latest 5 posts from select categories, all using a single query. I want the loop to display the category name followed by the 5 posts, and then ...
1
vote
0answers
16 views

Orderby is working with one query but not with other

I'm using a shortcode to show some price boxes. I use a CPT with a custom field called 'posicion' which has a number that I use later to customize the loop. This is the code: <?php if ( ! defined( ...
0
votes
1answer
15 views

Query for current post

I want to show current post.I will use this query in single template for custom post type.When click the custom post type, only the post will shown. How can I write this query? In wordpress ...
0
votes
0answers
14 views

Try to fix Image outside <a> container

I am using the latest Twenty eleven theme/Wordpress and Woocommerce. Some pages with shortcode such as [woocommerce_cart] without contents came out with the image outside container problem. See the ...
0
votes
1answer
10 views

How to search through all child taxonomies using WP_Query?

I need to create a page in which I can search through child taxonomies(custom child-category) based on GET request (For example $_GET['search_cat']) using WP_QUERY. I just want to list all of the sub-...

1
2 3 4 5
102