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.

0
votes
0answers
3 views

WooCommerce Custom Query with high/low pricing and paging

I created a custom query in my template to show certain products. I would like to add a sort feature for pricing ascending and descending but have not had any luck. Here is my code on my template: &...
0
votes
0answers
2 views

Query a Custom Post Type using SELECT that has ACF fields to compare dates

So I have a CPT called ads that has ACF fields of ad_start_date and ad_end_date. I am trying to write a custom WP query using a SELECT statement instead of using WP_Query because I am return an ajax ...
0
votes
1answer
10 views

Order by meta date with a thousanth of a second defaults to post order

I have a custom post type query: $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'paged' => $paged, 'post_type' => 'my_custom_post_type', '...
-1
votes
0answers
13 views

How can i fix google map issue in my wordpress site

The name of this JQMap Route Calc this plugin provides to calculate a route from point to point. use Google API 3 I bought this plugin on codecanyon but unfortunately the author didn't support ...
0
votes
0answers
29 views

wordpress $wp_query->query_vars[ 'page' ] query to fetching url data

I have 2 wordpress pages template pr1.php and pr2.php . The pr1.php has links below that sends data to pr2.php as below 1st: https://my_domain.com/pr2/683/ 2nd: https://my_domain.com/pr2/683b/ 3rd: ...
0
votes
1answer
10 views

Using post_where filter only on main query NOT sidebard new WP_Query

I have a post where filter set up for a CPT archive page. Which works great but i have other WP_Query objects in the sidebar that dont work because the post_where filter is effecting those Objects ...
0
votes
0answers
19 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
0
votes
0answers
23 views

How to merge these two post queries?

How can I consolidate the queries below... ? Query 1: Any posts with the "Topic" taxonomy term, eg. "Music" Query 2: Any posts attached to a "Company" taxonomy term, eg. "Spotify", which itself has ...
0
votes
0answers
43 views

How do I use $wp_query->current_post with get_template_part? I'm trying to add post classes (first/last/even/odd) to custom loops

... but $wp_query->current_post and the like don't work when I use get_template_part to pull in content.php files as modeled by themes like twentynineteen. The variables don't carry over I guess? Is ...
0
votes
0answers
19 views

How to include custom post types and custom taxonomies with WP_Query

Hi guys there any way to include or join custom post types and custom taxonomies with WP_Query below? static function &get_wp_query ($atts = '', $paged = '') { $args = self::...
0
votes
0answers
14 views

Lazy Loading using Pagination

im doing a lazy loading with WP_Query Pagination it's working fine but the content duplicate itself when it reaches it's end here is my code lazy-load.php <?php add_action('...
0
votes
0answers
12 views

How to store value in some variable in wordpress?

please help me I am new in WordPress the task is I have a URL like this http://localhost/talha/?aid=1 I want to store that URL value in a variable and use it through all my website. I read many ...
0
votes
1answer
17 views

How to avoid bypass of search bar rules?

I’m building my site locally. Since I want users to be able to write only specific terms in the search bar, I put a jQuery script in the wp-content\themes\sitename\js folder. The script works fine, ...
0
votes
0answers
10 views

Loading Youtube Video Methods

I have a post grid where i can make the youtube video grids but if loaded directly it results in a very slow website. Also ends up javascript render block. In WordPress how can this be handled? Is ...
0
votes
1answer
13 views

Why pagination is not working with tax_query param?

this is my query: $p_query = new WP_Query(array( 'post_type' => $post_type ,'post_status' => 'publish' ,'posts_per_page' => $per_page // 6 ,'paged' => $page // 2 ,'...
0
votes
1answer
9 views

Yoast primary category query modification

I have a problem with Yoast and displaying my primary category alongside rest of the posts from that category. Let's say I have 4 posts, all of them are lorem category and one post has set lorem as ...
-1
votes
0answers
22 views

How to display Top rated Posts based on average rating? [duplicate]

I am using custom star rating field in post comment form where visitor rate post with comment. The rating value is stored in comment meta table.I want to display 5 top rated posts based on average ...
0
votes
0answers
26 views

Translating WP query into to SQL query

I have very complex wp query and I want to use sql query instead of this. Is there any way to translate wp query to sql query. I am thinking that I will have a better control over sql query as the wp ...
0
votes
0answers
16 views

Remove post name of custom WP_Query when using in pagination?

Is this possible? I am trying to get pagination working on my pages and single pages. It seems like it's working, as it recognizes how many pages there are and shows the URL. The problem: the URL is ...
0
votes
2answers
12 views

List all ACF field values across every post on one page

I used an ACF repeater field for data sheets/instruction manual download links of products in woocommerce. There's 50 products and each has 1 to 4 download links on their product page. I've been ...
0
votes
1answer
22 views

Returning a custom content types with meta values

I find myself facing a situation where I will have a bunch of custom post types and I want to select those with specific meta values. There is a slight wrinkle in that the value I want to select ...
0
votes
1answer
24 views

How to invoke a HTML custom button based on a HTML dropdownlist menu

I am a WordPress beginner and want a help I created a HTML dropdown list like this: <select name="DropDownList1" id="DropDownList1"> <option value="select you location">&#xf015 ...
0
votes
1answer
24 views

Display the search results like the original pages

I'm creating my site (locally) and I'm using the starter theme underscores.me I created few pages using bold, italic, and other text styles, but I noticed that in the Search Results page, the content ...
1
vote
3answers
36 views

List of the years with posts presented

I need to get a list of the years with posts of given category. Like this: 2008, 2009, 2010, 2012, 2013 (if there were no posts in 2011, it's not included). I try this query, and it works — I get my ...
-1
votes
1answer
21 views

Get users query makes the site loading time too big?

I'm trying to get the top 10 users in (specific roles) by the highest post views, but this code makes the site loading time too big, and I don't know why! I'm highly appreciated your help. <?php ...
0
votes
2answers
47 views

meta query multiple values for the same key

I'm trying to query wordpress with multiple values but it looks like it can't take no more than 4 keywords I'm currently using a loop and I already tried to switch to a IN operator but I need the ...
1
vote
0answers
37 views

Removing noindex posts from wp_query

I have a blog website with some old posts and they appear in my "featured" posts section. I put those posts with noindex and but they still show up. is there a way to remove them from wp_query?
0
votes
1answer
10 views

Problem with get_page_by_path() using with WP_Query

I get error when i use get_page_by_path() with WP_Query in a php class. I use after_switch_theme and switch_theme in that class. And while the theme is activated then everything is fine as expected. ...
0
votes
0answers
21 views

Wordpress search query, how to modify the sql

I have a problem with the query search, which means I would only look for posts with post_status = published. The problem is that after adding my conditions, wordpress writes an "OR wp_terms.name LIKE%...
0
votes
0answers
7 views

Connecting from WP with WPML plugin to another WP db without WPML plugin

I am connecting to another Wordpress instance (using same database but different table prefix) from my main Wordpress site. My main wordpress site has WPML plugin activated but second site has not. I ...
0
votes
1answer
85 views

How to get top rated posts using wp query?

I want to get top rated posts using wp query. The rating value is store in comment meta database table when some one post a comment on wp post or cpt.Please screenshot EDIT Here is my code ...
0
votes
1answer
23 views

Pagination on archive.php not working?

My pagination isn't working for my archive.php, which I'm using as a template for my blog post categories links. <div class="row"> <?php $the_query = new WP_Query( array( ...
0
votes
1answer
12 views

Wordpress wp_query() basic question about args

Can someone tell me the comparison of these three query statement: 1/ Is it nline code ? I don't know what is it call. $getposts->query('post_type=projects&taxonomy=projects_categories&...
0
votes
0answers
28 views

Modify post image in full size

I have a website where the client attached many “full size” images to posts, most of them in 5000px width, is it possible to run something for resizing those images to large? Instead of going through ...
1
vote
1answer
21 views

Custom WP Query on custom meta and sort by multiple meta keys value

I am testing something out and I have a query like this: $paged = 1; $filter_min_price = 5; $filter_max_price = 300; $products5_cat_term_id = 368; $filter_brand = "Now, Garmin"; $sort_order = "ASC"; ...
0
votes
0answers
39 views

Slow page loads due to WordPress Core Query

I have a page with many posts and every single page load is noticably slow. Hence, I have checked with Query Monitor the culprit(s) for the slow loading time and found that one query in particular is ...
0
votes
1answer
37 views

How to create page with post content in it?

I have a page that I would like users to remain on. It is like a reference guide. Hence I would like to load post content into the page without the header / sidebar etc. Just the post content. ...
0
votes
1answer
40 views

Finding post ID dynamically on click

Goal: I'm making a portfolio website in Wordpress. It's the first time that I have setup a Wordpress page by myself (I have done on internship but those were template-ish). I have seen this website ...
0
votes
1answer
18 views

How to display upcoming events by dat with Modern Events Calendar Lite

I'm using the plugin Modern Events Calendar Lite. This is a recent plugin, so actually no doc exist. So i'm looking a way to display my upcoming events on homepage. But i can not make it to work, ...
1
vote
1answer
20 views

How do I use `posts_distinct` correctly?

I've scoured the interwebs but can't find a good working example or discussion of the filter posts_distinct I'm using Advanced Custom Fields but I don't think that could be the problem. Anyway, ...
0
votes
1answer
45 views

How to use jQuery validation to set the search bar to accept only a specific input?

I'm new to the wordpress world. As a starter theme I was suggested to use the basic one given by underscores.me. The search bar is fundamental for my site, so I would like to customize it in order to ...
0
votes
0answers
21 views

Wp-query output correct, but the loop shows one less item (only sometimes)

My site is making a strange bug, the code below works 99% of the times but every now and then it return only 2 items in the loop, even that the query results have more products // get the cats this ...
0
votes
1answer
8 views

Access Wordpress query by index number outside the loop

In wordpress query, Can I single out the specific post by index number of the query result? for example <?php $args = array( 'post_type' => 'headimages', ...
0
votes
1answer
15 views

paginate_links method doesn't show second page of my custom wp_query

I'm trying to create a custom search page using wp_query. I'm using post method to get search values. At first, the search was doing fine, but when i got a search results of more than 4 posts (i set 4 ...
0
votes
1answer
22 views

WP Query with meta queries

I have the following WP_Query: $query = new WP_Query(array( 'post_type' => 'some_cpt', 'posts_per_page' => -1, 'meta_key' => 'active', 'meta_value' => 1, '...
0
votes
1answer
20 views

Unusual high query of user meta data

We have a WordPress installation with many plugins installed. The site is not that highly frequented (maybe 10-20 concurrent users). I know the amount of plugins comes at a cost of performance. ...
1
vote
1answer
34 views

Change default ordering of taxonomy terms - pre_get_terms

I wanted to change the default taxonomy terms order by its 'term_order' value instead of 'name' in admin side. So I tried something like below. But it doesn't work and php memory exhaust. function ...
0
votes
1answer
19 views

Exclude parent categories from recent posts list

I want to show only the sub-categories from a post's specific parent category and exclude all the other categories. This is for a loop of recent posts on my front-page.php. Each recent post is ...
-1
votes
0answers
12 views

SMTP Error: Could not authenticate

I get the error "SMTP Error: Could not authenticate" even all these things are set in Easy WP SMTP Settings (Encryption type: SSL Port: 465 Requires Authentication: Yes)
0
votes
0answers
11 views

sql query page listing with option selected

I want to separate a page page from the sql query. for example current page and last page with option selected. my listing page code <ul class="list-group"> <h2 class="h3">...