Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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 given request.

0
votes
0answers
17 views

WP Query and multiple queries

I have a registration form that I'm trying to put limits on sign ups for specific characters. I've added fields for each character with a checkbox. I have this code that I'm working through that's ...
1
vote
2answers
22 views

AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely

I have multiple wp_query's on the same page. Each one of those queries has an AJAX "read more" button at the bottom. The problem I'm finding is that I can only get one to work at a time. Whichever ...
0
votes
0answers
11 views

Create custom design for posts loop with pagination

I need to create a simple posts loop to be shown on the homepage (Meaning - I am in "page" and not "blog" or "archive" This is what I need: Display maximum of 5 posts there will be arrows on both ...
0
votes
1answer
39 views

why does not my wp_query work?

i want to display archive of posts for post type of post. so i created a page template and insert the following codes but i display nothing. why? what should i do? <?php $postnumcat = new ...
0
votes
0answers
4 views

WP meta query: multiple date compares if datepicker is not null

I am trying to build a meta_query which will return all posts that have at least one of their datepicker value greater than today. If the value of the datepicker is null then I don't want to be ...
0
votes
1answer
22 views

Order by Date Custom Field

I'm trying to display a list of upcoming football matches in order of kick off. The code I currently have lists the dates in the correct order but the posts ordering is incorrect. $previews_new_loop =...
0
votes
0answers
14 views

How to upload 3 attachments to current post?

I have a form which updates a post but when updating I need to be able to also upload 3 posts: <div class="form-group"> <input class="form-control" type="file" tabindex="3" name="custom-...
0
votes
1answer
13 views

Custom post types - meta_query: search lesson which starts sooner

I have lesson custom post types which have 4 date sub fields (among others): period_a_start, period_b_start, period_c_start, period_d_start. I want to create a query to get the 8 first lessons that ...
-1
votes
0answers
22 views

Including WP-Load Causing Issue on PHP - MySQLi Prepared Statement

I have a custom php file and trying to run WP_Query there by including the wp-load.php file there. The file is simply getting some data from external table like require_once "config.php"; $myArray = ...
0
votes
1answer
14 views

What's the best way to query from custom table?

I installed a standard theme. Now I have to create a static site with custom queries. Customer should enter own age and family status etc., the following query results in showing insurance rates in a ...
-1
votes
2answers
24 views

wp_query get data from advanced custom field in wordpress

I want to get the data from advanced custom field using wp_query from another custom post type: $title = get_the_title(); $the_query = new WP_Query( array( 'posts_per_page'=>9, '...
0
votes
2answers
32 views

Query a custom taxonomy in a function to create an csv file

I a problem with getting the query for custom taxonomy to work in this function. The $filter is filled with data but the get_posts() does not use it? The query works without the tax_query and there ...
1
vote
1answer
14 views

Custom page archive query by url var calling page twice on one of my custom queries?

This is such an odd issue. I will try and break it down as simply as I can. I am creating my own custom page query which works like an archive using url variables to customise the query results. ...
0
votes
0answers
12 views

show arabic posts on arabic page and show english posts on english pages using $wpb_all_query

I'm using this line to get all the posts with the category "Upcoming Event" $wpb_all_query = new WP_Query(array('post_type'=>'post', 'category_name' => 'Upcoming Event', 'post_status'=>'...
0
votes
0answers
16 views

Check the product in the cart from which category is and show message

I want to check the product in cart from which category is and if is from Category X to show some message. So far I've done this and I've placed it in checkout.php $categories = array('cat' => '...
0
votes
0answers
39 views

Query with multiple CPT but custom field for only one on them

I need the query with merge of two CPT posts (for example cpt1 & cpt2). The problem is when is need to add the 'variable' only for one CPT, that is the a custom field and relevant value (for ...
0
votes
1answer
43 views

Add date & time and latest post option in top bar of wordpress site [on hold]

I want to add the current date & time as well as latest post to be shown in the top bar of my WordPress site. If you have any idea please let me know that how to add all these options, when my ...
0
votes
1answer
18 views

wp_query comment and meta query

I making wp_query that control comment-count, and meta key value. So, I coded like this. but is doesn't work. When I use comment_cout only or meta_query only, it works good. when I use together, it ...
0
votes
0answers
17 views

Unexpected results when passing WP_Query from Search and Filter Pro to Geomashup, with the results updated via AJAX

I'm using two plugins in tandem, GeoMashup and Search and Filter Pro. Geomashup is generating a contextual map of posts from search results passed from Search and Filter Pro. I need the results ...
0
votes
1answer
30 views

WP_Query To Display Product Of Brand On Taxonomy Page

I am trying to print all products of a brand on a taxonomy page. I find the wp_querry but i cant print the current brand name of the brand to show all products in this page. What to put on terms ...
0
votes
1answer
22 views

Need to add onclick javascript at backend of my wordpress site

I don't know much about coding as I am not a developer. I have owned a WordPress blog and I want to track the number of users has submitted the contact form. As it does not redirect to Thankyou page, ...
1
vote
2answers
20 views

Wordpress loop: Show only a Custom Post Type Taxononmy TERM

Before I start, I have to say that I have tried to solve my problem in a thousand different ways and I have read several posts without success. I have a CPT called "grouped", a taxonomy for that CPT ...
0
votes
0answers
15 views

Related posts by many fields with OR - WP Query

I would like to have related posts on my webpage. The idea is to show everything that is related to this post, so the author could be the same, tags or category(I assume that post have only one) - ...
0
votes
0answers
13 views

How to filter on placeholder image

I'm using the woocommerce-auto-category-thumbnails plugin to replace a blank category thumbnail with a random thumbnail from one of the products in the category (or child categories). It is supposed ...
0
votes
1answer
24 views

WP_Query showing all posts, except from category X, unless it's also in Y

I'm trying to show posts from categories A, B, C, D...and Y, except X, unless posts in X are also in Y, then show them with the rest. I can hide category X on it's own pretty simply: $args = array( ...
0
votes
0answers
21 views

In a WordPress multisite configuration, how do I instruct WP_Query() to return posts from a sub-site?

I have a WordPress multisite with one main site and four sub-sites. All five sites have a custom post type with the name property, and each site has several posts of this type. In a PHP template on ...
0
votes
1answer
22 views

WP Query - Posts Per Page not working in combination with category__in

I'm not sure whether it's a bug or i'm doing something wrong, but it doesn't seem like posts_per_page works at all when using category__in. My query is below, even though I've set posts_per_page to 1,...
0
votes
0answers
10 views

How to query SQL for coords nearest a point? [migrated]

This is what i am trying to do: From a form I GET the coordinates: &usp-custom-20=45.492384716155605&usp-custom-19=9.206341950000024 The I query SQl to find all posts near those coordinates,...
0
votes
0answers
13 views

How to add a custom page as menu item “selection”?

Sorry for the confusing title; I do not know how to explain this in one question. I want to add a navigation item that can be added to menus. In other words, I want to write a function that will ...
0
votes
0answers
17 views

Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop

I'm aware there are already answers regarding this question (Insert html after certain amount of posts?). But I haven't managed to find a solutions to my specific problem. The post linked above rely's ...
0
votes
0answers
9 views

How can I query a radius of coordinates?

This is what I am trying // Each post have a field with coords like: // The value is a string usp-custom-90 = 45.46135436613811,9.175124650000043 // Here I am getting some coords from a form // ...
0
votes
0answers
19 views

How to query for exact string in custom field?

I have a custom field which I set in a var $customCoords = usp_get_meta(false, 'usp-custom-90'); That custom field has a string like this: 45.46135436613811,9.175124650000043 Then I get some ...
0
votes
1answer
22 views

Wp Query sort order from custom MetaBox

I am trying to sort a list of post based of the meta_key deal amount, which would be to display the highest deal first and work its way down to smaller deal amounts. The deal amount would be anywhere ...
0
votes
1answer
20 views

Show post content and title in diferent divs using WP_Query using a loop

im trying to display the post title and post content of posts in diferent divs using a loop to iterate the posts in $the_query, how can achieve this? <?php $the_query = new WP_Query( '...
0
votes
1answer
27 views

ACF Post Object meta-query by title not ID

I'm trying to query a post type (intervention) via a post object field (intervention_country) by the title (of the related custom post type - country). Something like: $wp_query = new WP_Query(); $...
0
votes
1answer
8 views

I need query_posts() to order results first by a meta value and then by post ID

I've read all the WordPress docs that seem relevant, and I've read lots of posts here and on other sites to find an answer to this, but I still can't find a way to do this. I have a custom post type. ...
0
votes
0answers
18 views

Paginate default 'Posts' post type in other pages

I have an 'Event' post type and paginating it in archive-event.php without a problem. $today = date('Ymd'); $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; $args = ...
-1
votes
0answers
17 views

how do I add an article to the title?

function __search_by_title_only( $search, &$wp_query ) { global $wpdb; if(empty($search)) { return $search; // skip processing - no search term in query } $searchTitle = $...
0
votes
0answers
22 views

Show posts with a specific category or aithor

Im creating a custom feed for users on my website, where each one can follow users and categories and see post from them. I'm not really sure how though. I have tried to use author__in and ...
0
votes
0answers
24 views

WP_query with pagination gives a 404 after page 1

So i couldn't display a custom pagination on a custom wp_query index.php page and then found this answer wordpress.stackexchange.com/questions/160175/pagination-on-a-wp-query-not-showing-navigation-...
0
votes
0answers
11 views

AJAX and History API for the default wordpress pagination

What I want to achieve is AJAX-ified pagination for the WordPress archive/pages/posts etc meaning that I would like to keep the standard URL structure: example.com/page/2/ but using the combination ...
1
vote
0answers
20 views

How can I made custom taxonomies relationship?

I create two custom taxonomies: Category (Cars, Pets etc). Region (New York, Washington etc). Now I need to do archives like {Category} in {Region} (for ex. Cars in New York) and get slugs for it (...
0
votes
0answers
18 views

WP_Query: compare multiple values with serialized data in database

I am using WP_Query and I need to compare multiple dates with a meta_key named data_evento, containing multiple dates as well. If at least one date is matched, corresponding posts should be returned. ...
0
votes
0answers
42 views

$wpdb->insert with wordpress shortcode

I hope someone could help me! I need help about Wordpress shortcode with $wpdb->insert. It works, but it run TWICE... function f_registrazione() { $output = ''; if(!$_POST['txtNome']) { ...
0
votes
2answers
32 views

Case insensitive ORDERBY in wpquery

I'm trying to sort custom posts in alphabetical order, and I've just now realized that capital letters are being sorted before lowercase. Two restaurants start with 'Cal' and 'CAT' with 'CAT' being ...
0
votes
0answers
14 views

Loop Query - How do I use WP_Query with the standard Wordpress querystrings?

I am wondering on the best way to approach a particular (common) scenario. I have a standard wordpress website, with various pages. I have one page currently designated to be the "blog" - this is ...
0
votes
0answers
16 views

How to modify archive pages URLs to include dynamic prefix?

I am building a website in WP where content (news, announcements, events) are grouped by regions (e.g london, nyc, ...; these are custom post types). In all the contents, I have a meta box where I can ...
0
votes
1answer
13 views

custom excerpt is not being shown

I am trying to show custom excerpt using the_excerpt(). the full code is as follows: <div id="content"> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(...
1
vote
2answers
20 views

Getting Taxonomy inside WP_Query Loop

I have written my custom WP_Query and using loop to display post content. I use get_the_category() to display categories of current post and it works fine. Now for some post types there are custom ...
0
votes
0answers
15 views

Sorting with meta_query and multiple, optional meta keys

I'm trying to sort a custom post type by 3 properties: Meta Key: is_featured Meta Key: is_primary Title The two keys are boolean ACF items, and are both optional, so most of the posts don't have the ...