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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

"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.

-1
votes
1answer
11 views

Searching Custom Posts content with JQuery

I am adapting the site's archive pages for CPT's to use a masonry layout and adding a live search to the archive page. I have a setup that is working. However I've just realized that my script will ...
1
vote
1answer
16 views

prevent showing posts of an specific category in admin posts section

For some purposes I made a plugin that automatically makes posts with a specific category. Now in admin posts section, posts with that specific category have been too plentyfull and finding other ...
0
votes
0answers
10 views

Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?

I am trying to see if there is a way to have the sub-menu items change depending the taxonomy of the of the page that is in the menu? I currently use the following WP_Query I use to grab the top three ...
0
votes
0answers
8 views

How hide post from loop with a certain field?

I have this code: <?php /** * WP Job Manager Related Jobs * */ function wpjm_related_jobs_display($options=array()) { if(!count($options)) $options=get_option('wpjm_related_jobs'); ...
1
vote
1answer
19 views

How to select events within current week using wp_query

I'm trying to create an events page that lists events (custom post type) within the week. I'm having trouble properly selecting only the posts that have a 'start_date' that falls in the current week. ...
0
votes
0answers
14 views

Get post grandparent value [duplicate]

I have the following page structure within WordPress Grandparent Parent Parent Child Child Child Child Parent Parent Parent ...
0
votes
0answers
21 views

Finding the places saved in database ,nearby the given address using wordpress

I have a custom post named stores ,in that each post contains the full details about the specific store, including the geo location. Then i have a search box in front end where the users can search ...
-3
votes
0answers
26 views

Redirect If Search Query Contains Any Bad Word

I am looking for a WordPress php function for an Education website with following functionality: Redirect to a specific page - If user search for a query that contains any bad word from the given ...
0
votes
1answer
21 views

How to display last whole post on the homepage

I try to show on my homepage only the last post, in complete version. I tried numerous methods unsuccessfully. I tried in particular to create a specific template: “front-page.php”, in which I put ...
0
votes
0answers
23 views

Pagination problems

I have a custom taxonomy called "editii" with the slug editii. when going to the https://www.trendshrb.ro/editii/ I get there a archive listing showing me all the posts from the site not only the ...
0
votes
1answer
15 views

How to hide posts of a specific custom category in Wordpress?

I have 2 custom post types on Wordpress website - Location and Event. Location is connected with Event as meta data (for sorting). For example: some event (Event post type) is taking place in London (...
2
votes
3answers
80 views

Getting an array out of WPQuery

I have a query like this i will get the id's for product. This works fine: function ids(){ $args = array( 'numberposts' => -1, 'post_type' => 'product', '...
0
votes
1answer
29 views

Filter custom WP_Query by first letter of a custom field - hopefully using Search and Filter Pro?

I have a custom WP_query that very simply filters a custom post type: <?php $query = new WP_Query( array( 'post_type' => 'professionals', 'search_filter_id' => '204' ) ); ?...
0
votes
1answer
18 views

How to get post from all Blog Multisite to the Main Site?

How do I display all posts from multisite to the main site? Please help me. thanks.
4
votes
2answers
72 views

WP_Query orderby custom field then post_date in one query

I need to order the first three posts by a custom field, and subsequent posts by post_date in one query - for example: Post 4 (field_order: 1) Post 3 (field_order: 2) Post 2 (field_order: 3) Post 1 (...
0
votes
1answer
12 views

Filtering posts for unique titles, only the most recent

I am trying to understand how I can fetch posts for an archive that: Have a unique title Are the most recent version of said unique title So, if I have 3 posts: title: 'ID1: My Title' date: 01/01/...
2
votes
1answer
46 views

How to query serialized array by comparing greater than (>=)?

I have serialized post meta values. It looks like this: In array: $kisiArray = array( 'option1' => 7, 'option2' => 'bar', 'option3' => 'apple', 'option4' => 'orange' ); And ...
0
votes
1answer
16 views

Page navigation doesn't seem to work when I add offset?

I am trying to get a simple navigation to work, it works when I don't use offset in the arguments. but I like to do something special with the first post $paged = ( get_query_var('paged') ) ? ...
3
votes
3answers
98 views

Query Custom Post Type taxonomy type based on page

I have a Custom Post Type called books. This Custom Post Type has a taxonomy called book_category. As of now, and in the foreseeable future, there are 5 categories each book can be filtered under. ...
0
votes
1answer
13 views

404 page on custom search pagination

I have to kinds of search forms in my sidebar. Both of this forms are handled in search.php page by an if/else statement and write a custom query for both of them. I also replace the default wordpress ...
0
votes
0answers
16 views

Blog post query, post that contains query return page information instead post information,

I am using a simple query to show 6 of my blog posts. The blog post title, author and date are showing BUT, I have one post that have a query of one of my custom post in its content, this post when ...
0
votes
0answers
12 views

Functions than depending on wp_query global not working with AJAX

I have an ajax infinite scroll posts system and I have a problem that the posts that loaded by the system some function not working with it. Example: I want to appear a message if the current page ...
0
votes
1answer
31 views

How to access custom Wordpress database tables

I have this sample code that I found online that's supposed to count the number of rows in a table. Of course... It works, but when I created my own table using phpMyAdmin... It no longer works. What ...
2
votes
1answer
232 views

Why should i use wp_reset_postdata()?

I am not able to understand the use of wp_reset_postdata. what could go wrong if i am not using it? https://codex.wordpress.org/Function_Reference/wp_reset_postdata Here in documentation what is ...
1
vote
2answers
23 views

How to get posts on a specific date - WP Query

I want to get posts of a specific date, I tried the following code but I did not get the result what I wanted. <?php $mil = 1532996880000; $seconds = $mil / 1000; $dt = date( "Y-m-d", $seconds ); ...
0
votes
1answer
16 views

Prevent WordPress automatically processing certain URL queries

I'm coding a custom plugin for a client and I want to use certain $_GET variables in the URL in my custom pages, such as ?s=$1, ?p=$1 and ?paged=$1. With some of these variables, such as ?paged=$1, it ...
1
vote
0answers
30 views

Woocommerce query specific product from specific category

I'm trying to create a shortcode that will show a woocommerce product via just a shortcode. I want the shortcode to take 1 parameter that is either the ID or slug of the actual product. Preferably ...
1
vote
1answer
64 views

How to list custom fields as headers and list all pages sharing that custom field under it?

I'm trying to use a custom field of "State" to list all the city pages for available locations. I'm able to get the right results, in the (alphabetical by state) right order with this code: <?php ...
1
vote
1answer
24 views

query offset countdown by 2 each day?

Everything I've tried has been bust... so I'm here asking for help. I'm looking for a way to set a defined offset number (say offset=1000) that will count down by 2 and reset when it's reached 0 (if ...
1
vote
2answers
27 views

Get and Trim Full Post Content in WP Query

Simple task, but it isn't working: <?php $content = apply_filters( 'the_content', get_the_content() ); $contentWithoutHTML = wp_strip_all_tags($content); $pos = strpos($contentWithoutHTML, " ", ...
2
votes
0answers
28 views

Get the Plugin Which Triggered a MySql Query in Wordpress?

I am currently working on this plugin, which is similar to Query Monitor in which i Have displayed all the Details present in the $wpdb object. Now i need to find which plugin is Triggering the Query. ...
0
votes
1answer
31 views

Quickest way to get last or oldest post date - WP Query

I know how to get the last or oldest post data using following code $posts = get_posts(array( 'post_type' => 'post', 'order_by' => 'publish_date', 'order' => 'ASC' )); And then I will ...
1
vote
2answers
35 views

How to delete taxonomy term when a wordpress user is removed?

i need to Delete wp_terms -> name field when a user is delete . my requirement is admin needs to assign posts to specific users, that is admin need to add a post to user1 ,but user2 should not see ...
1
vote
1answer
11 views

Reset Popular post query?

I am using the following code to display most read articles. I think it takes the lifetime of the articles as it displays very old articles first. How can I reset it - weekly? in my function.php ...
2
votes
1answer
33 views

How to get previous 10 days post from a specific date - WP Query

I want to know how to get previous 10 days post from a specific date, as I know that it can be done from current date as below $args = array( 'post_type' => 'post', 'date_query' => ...
0
votes
2answers
25 views

how to get post order by post id wp_query?

i have 4 post and i displaying 2 post per page. $ids = array('16085','16088','16083','16091'); $options = array( 'post_type' => $post_type, 'posts_per_page' => $posts_per_page, ...
1
vote
1answer
15 views

Ajax WP_Query reutrns no results on author.php

I have an Ajax call for loading more posts on button click. The Ajax is generating a new WP_Query according to some arguments it gets from a form, then send the posts it gets back to the page. It's ...
0
votes
2answers
26 views

How to insert wp_users ->user login name to wp_terms when a new user registering?

i need to insert wp_users -> user_login field to wp_terms name and slugs field,when a new user registering. my requirement is admin needs to assign posts to specific users, that is admin need to ...
1
vote
1answer
29 views

Custom query based on meta key - Reduce three states to two in results?

$args = array( 'post_type' => 'bars', 'posts_per_page' => -1 'orderby' => array( 'meta_value' => 'DESC', 'title' => 'ASC' ), 'meta_query'...
1
vote
1answer
32 views

Best practice for query_posts in responsive design?

I'm working on a responsive design desktop/mobile but I have a doubt regarding PHP calls, as the hosting provider didn't like high cpu usage. In the loop query I have something like this: <?php ...
0
votes
1answer
25 views

Repeat array inside array through while loop

I want to repeat this array: array( 'taxonomy' => $tax, 'field' => 'slug', 'terms' => $cat, ) because I am getting the value of taxonomy and categories from custom sub ...
0
votes
2answers
36 views

Custon Content within WordPress Loop

I have created a WP loop to display Services from 'Services' Custom Post Type: Here is the code: <?php $services_loop = new WP_Query( array( 'post_type' => 'service', 'posts_per_page' =&...
1
vote
3answers
36 views

WP_Query no posts with tax_query

When I add a new WP_Query, everything works, but if I add a 'tax_query' with a taxonomy, it doesn't pull the posts. post_count would always be 0. $products = new WP_Query([ 'post_type' =&...
1
vote
0answers
20 views

How to Union two different conditions in one WP_Query

I need to query in one WP_Query: All posts that are children of category id = 6 and also the posts in category 7 but only those that have been checked a custom field of ACF (true / false). In SQL ...
1
vote
1answer
16 views

how to make members list directory through wordpress post custom meta key.

I have created a website in which I am providing complete information about the organization. For this, I am using a Wordpress post. In which I am putting information of only one organization in a ...
1
vote
2answers
24 views

WP_Query Ignoring `post_type` parameter

<?php $args = array( 'post_type'=>'weather_today', 'orderby'=>'ID', 'order'=>'ASC', 'posts_per_page'=>1 ); $query = new WP_Query($args); ...
2
votes
0answers
37 views

Wordpress posts per page WP_Query

I'm trying to limit the posts per page using WP_Query. Please see the code below and see why it doesn't work for me: public function widget( $args, $instance ) { // outputs the content of ...
1
vote
0answers
11 views

Masonry, WP_Query & paged - first page repeating, second page not loading

I'm tearing my hair out over this. I've been tasked with some legacy work on a quite an old site. They have a template for a custom post type called resources. This template has search/filtering ...
2
votes
1answer
31 views

wordpress query in header won't reset and corrupts other loops

In a template part in my header, I have the following code: $args = array('post_type'=>'weather_today','orderby'=>'ID','order'=>'ASC','posts_per_page'=>1); $query = new WP_Query($args); $...
1
vote
0answers
23 views

Display filtered results into custom page

I am trying to use the "Search and Filter" plugin to give a wp_query filters, but I don't want it to go to the search.php file. I want the results to be pulled up on the current page. I have searched ...