"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

-1
votes
1answer
17 views

List posts related to category on a div [on hold]

i want to display posts related to selected category at the same page(on a different div). What i want is as the image attached, when i click the category name on the left side, all related posts must ...
0
votes
2answers
27 views

Query posts by a type and another type only if post is in specific category

I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted? A crude ...
0
votes
1answer
22 views

Order post type by sum of two custom fields

I have a custom post type for vouchers. I've added two custom fields to this post type named "value_1" and "value_2". They both contain a number. (The first value will be applied at checkout, the ...
1
vote
2answers
71 views

Why won't my taxonomy query show up?

I'm attempting to display posts from a 'Uncategorized' category under a custom taxonomy called 'Reviews' but without much luck. I'm using get_template_part('loop','review') to call loop-review.php ...
-1
votes
0answers
15 views

WooCommerce order by “rating” [on hold]

I have this shortcode, to show the featured products, but I want to order them by the rating, anyone know how can I do this? Shortcode: function featured_products_shortcode($atts, $content='') { ...
0
votes
1answer
21 views

How to create Page templates for showing Blog posts in different layouts?

I'm creating a Wordpress Theme, and I want to create few Page Templates for creating Blog pages with different layouts. So for example, I want to have blog-4-column.php, blog-3column.php and ...
0
votes
1answer
16 views

Remove duplicated posts in the loop if post has more then one categorie

I have some posts with more then one categorie. In the post loop i get the post based on the selected categorie by the user. If the user select 2 categories where one post is assigned to, the loop ...
0
votes
1answer
60 views
+50

Custom Search Not Consistent with Results

I've set up a custom search to use the s GET variable on a URL. I want it to fetch certain results but I've come across an odd problem. First, here's my code: $search_term = $_GET['s']; ...
0
votes
0answers
18 views

Only show top level posts of specific category

I've been trying to create a loop that will only show the top level posts no children/sub category posts. Basically what my categories look like are -- -All --one --- A --- B -- ...
0
votes
0answers
21 views

Query by 2 values of a repeater ACF field

Let's say I have a custom post type called Film, with a repeater field called Showings, with fields start_datetime and discount. I need to make a query for those Films that have at least one showing ...
0
votes
0answers
18 views

WP_Query - How to orderby parent publish date?

I am using WP_Query to display 'post_type' => 'attachment' on a different page than the posts they are uploaded to: $media_args = array( 'post_type' => 'attachment', 'post_status' => ...
0
votes
0answers
12 views

Filter terms bases on multiple taxonomies - operator not in? [duplicate]

Building a function for filtered taxonomies. How to use 'operator' => 'NOT IN' or 'operator' => 'IN' inside the query to only show tax_query terms that are connected to all taxonomies instead of ...
0
votes
1answer
30 views

relation OR instead of AND - Filtered term ID's in loop

Question not related anymore.. First I tought about the relation OR/ AND for results, but I believe I should work with 'operator' => 'NOT IN'. I would like to query the results that meet multiple ...
0
votes
1answer
25 views

Query seems to be duplicated

I'm just hit a development brick wall and can't seem to find a solution to this problem. I've running two WP_Query's the aim is one displays premium stockists and the other one displays the none ...
0
votes
2answers
38 views

Archive page - problem with pagination

I have a problem to display pagination using WP_Query. I've created a custom page, code below: <?php /* Template name: Models */ ?> <?php get_header(); ?> <?php the_post();?> ...
1
vote
1answer
35 views

Get current post id in functions.php

I have a wp_localize_script() function in my functions.php where I need to push the current post ID of the current post to a jQuery file. So I was wondering how you can get the current post ID of a ...
1
vote
1answer
27 views

get_the_title($postID) OR get_the_title()?

I would like to know which could be more performant between these two approaches of getting data of a post To use a loop after a WP_Query($aConditions) and use functions like get_the_title() ... and ...
6
votes
3answers
90 views

Can I force WP_Query to return no results?

I'm working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The ...
0
votes
0answers
34 views

Add custom fields meta_query to wordpress search function

I'm trying to extend the wordpress search function to include custom fields using the pre_get_posts filter: function test_custom_search_query( $query ) { $adv_custom_fields = array( 'field_1', ...
1
vote
2answers
36 views

Different Ways to Query Custom Post Types?

I'm using this code to use custom post types like regular post: add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() && ...
1
vote
1answer
22 views

Advanced Query Logic With Multiple Taxonomies

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three ...
1
vote
0answers
53 views

WP_Query tax_query problem

When I call WP_Query with tax query or category__in, I get posts only from first category in array of requested categories. $query = new WP_Query( array( "tax_query" => array( ...
1
vote
1answer
22 views

How to count post meta key values for all posts in database

In my post meta data I have the following 'key' for every post: "image_details" a typical value of which is an array such as: ...
1
vote
1answer
55 views

Show most popular post of last 12 months

I use the Ribbon theme that has a nice tabbed widget showing the most popular and most recent posts. I would like to limit the most popular posts to the last 12 months. I would rather not use a plugin ...
1
vote
1answer
48 views

Unable to get paginate_links working with a custom query [duplicate]

I have built a news section in my Wordpress site with the advanced custom fields and custom post type ui plugins. On the custom news overview page (not the standard wordpress posts) I wanted to limit ...
1
vote
0answers
11 views

Posts 2 Posts: Get related posts from user connected to current post? [closed]

Hopefully someone can help with this. I have a CPT called "Tours", and I'm using Posts 2 Posts to connect Posts inside that CPT to Users. Relationships being: Tour Item 1 > Tour Operator 1 Tour ...
0
votes
2answers
39 views

Using global $post; to get featured image for custom post via WP_Query

I'm using a site-wide function to add css to the <head> of the page pull in featured images of various as a responsive page background. It works great across the rest of my site but fails on a ...
1
vote
1answer
32 views

Hiding taxonomies with no children WP_Query & tax_query

I have this code which has taken over 7 hours to put together through research but the last hours or so I have hit a brick wall! I require the taxonomy title to be hidden if there are no posts ...
0
votes
1answer
38 views

Get first post from wp_query

How can I get the first post from a WP_Query result? $connected = new WP_Query( array( // Arguments )); // This doesn't work.. echo $connected[0]->post_name;
0
votes
0answers
33 views

Random posts loop order [duplicate]

I have used a loop for my theme homepage, but when I go to page 2 or 3, 4, etc., I get the same random posts in all pages. I want to make the loop generate different random posts each page. <?php ...
0
votes
1answer
8 views

Category based on post id

I have the following: $custom_loop = new WP_Query( array('category_name'=>$category, 'meta_key'=>'name', 'orderby' => 'meta_value', 'order' => 'ASC', 'posts_per_page'=>'-1')); How ...
0
votes
1answer
42 views

Why does WP_Query show only the same post even with different categories and endwhile?

I have 3 divs that WP_Query with 3 different categories and end it with the php endwhile,but it only shows the same most recent post query three times over. Do I need to hard reset the query loop ...
-1
votes
1answer
27 views

Renaming or Moving WP-Content Pros/Cons

I'm still learning WP. Previously I had done a 1-click installation of WP. Everything worked fine. But now, I'm planning to install it manually. What are the Pros/Cons of these? 1 Renaming ...
0
votes
1answer
21 views

Run next query based on first query's term

I'm creating an authors site. I'm using a custom post type (Books) to display books. I'm using another custom post type (Reviews) to display reviews on the same page as the corresponding book. I'm ...
0
votes
0answers
33 views

how to get sub fields using advanced custom fields?

I am a compete beginner with Advanced Custom Fields. I would like to get your help in understanding acf well, most probably a simple question. I have a blog I use acf to categorize the posts. I use ...
0
votes
2answers
49 views

WP_Query and is_page_template() conditional

I have a custom query that goes looks like this: $temp = $wp_query; $wp_query = null; $args = array('posts_per_page' => 5, 'post_type' => 'gallery', 'post_status' => ...
0
votes
1answer
24 views

meta_compare not comparing whole integer

I have submitted an integer data via a form to my custom search page. I can get values properly if the input is single char (e.g. 1 ) but if the input is multi char (e.g. 100) it still compares ...
-1
votes
0answers
16 views

Classes and Including Files on Init

Switching my plugin over to a class based system so it can be more easily expanded upon. I previously used global functions to set my rewrite rules, and to call them on init. I keep those in a ...
0
votes
0answers
17 views

include taxonomy terms in search query

I currently have a search query set up that only displays the post_type of listings in the search results, I want to amend this query to include a custom taxonomy also. I have a custom taxonomy for ...
1
vote
1answer
49 views

Search - Ajax - Alter Query Parameters with Pagination

Too Long ; Didn't Read How do I get pagination to work when I'm creating my query with ajax? I'm working on creating a functional search page that allows the user to filter how many posts per ...
-1
votes
0answers
15 views

Suggested posts from categories

I need a certain procedure to display suggested/similar posts for each post, but I've never done something like this, so I'd ask for some guidance: Take all the categories the current post belongs ...
0
votes
0answers
18 views

Querying Multiple Categories With Different Offsets

On my website I have a "Breaking News" section which shows the most recent 4 stories in the "Breaking News" Category. Under this I have a featured news section which displays 5 more stories from the ...
0
votes
0answers
21 views

Issue with permalinks for custom post type

I have a little issue here... When i'm using default permalinks, everything works great, but when I set up %postname% permalink in settings, my template with custom post type is not loaded. ...
1
vote
1answer
29 views

display posts with same taxonomy term

I'm trying to display 5 related posts in the loop, those related posts being posts that share the same taxonomy value. e.g. I have a custom taxonomy set up called venues thus each post has a venue ...
0
votes
1answer
16 views

'&' causes an error in my shortcode when I list the content of the page

I would like to list the specified pages with my shortcode, but the problems are with the '$' charachters. function get_page_func( $atts ) { extract(shortcode_atts( array( ...
0
votes
2answers
35 views

Get attached media only

I am using wp_query to get uploaded medias. Everything is working fine, but wp_query will return the medias with no post attached. This is not what I wanted. How can I exclude the unattached media ...
0
votes
0answers
35 views

New WP_Query loop in admin causes problems

I am working on a project where I have a custom post type 'companies' and on this edit page in the Wordpress admin I have some custom made meta boxes, for saving company information, opening hours, ...
2
votes
1answer
37 views

WordPress meta_query and order by custom field

I have a Custom Post Type called "Films", with a Repeater field called "Showings", which have a field "start_datetime" of type DateTime... I want to perform a query to get all those Films with a ...
0
votes
1answer
35 views

Not duplicating $post->ID leaves empty space.

My home page has a section at the top that displays a featured post from a time period if it has been set, otherwise it displays the most commented post of a time period, or it just displays the most ...
0
votes
1answer
40 views

Conditionals in WP_Query

What I'm trying to do is this: If in the last 7 days someone has added a post in the category 'featured' display it in the loop. Otherwise, display the most commented post from the last seven days. ...