Tagged Questions

"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

0
votes
1answer
27 views

ajax wp_query conditional tags not working

I'm trying to ajax wp_query, I got success getting posts for home page with the following code. Then I added conditional tags to modify the query for the other pages like Category page the problem ...
0
votes
1answer
29 views

Sort by custom field that is an array?

is it possible to sort posts inside a query based on post value that is in an array - but using the last element of the array? The code looks something like: <?php $mostsharedposts= new ...
0
votes
2answers
45 views

Custom taxonomy wp_query woes.

Here's a brief outline of the set-up: "The Art" CPT is where all the art and art descriptions are uploaded. In this CPT you can choose the category (custom taxonomy) of the art--painting, jewelry, ...
5
votes
1answer
164 views

How to Compare Two Meta Fields

Consider two meta fields balance and monthly_price. How you would get all posts that has balance < monthly_price Thinking of creating meta query but our both fields are arbitrary or do not have ...
1
vote
1answer
34 views

Date query not inclusive despite parameter being true

I've set up a small test query to get some posts from October 1 to October 10. I published a post today ( October 10 ) and with the date query parameter of include set to true, I would have expected ...
0
votes
0answers
13 views

Do not count menu items in posts_per_page

Custom type posts are added to query for category page: function test__pre_get_posts( $query ) { if( !is_home() ) { if( is_main_query() || is_category() ) { $query->set( 'post_type', ...
0
votes
0answers
37 views

how to show a tooltip include of thumbnail and excerpt when hovering a post link in other post?

Is there any way to call thumbnail and excerpt for link of post in another wordpress post? For example when i hover a post link in other posts, it shows a tooltip include of thumbnail, excerpt. Like ...
0
votes
0answers
39 views

WP Query to order posts by multiple meta fields

This question might have an answer already in the forums, however I still wanted to ask it as this is a different more complicated version of the problem. The story: We have 2 meta fields for ...
0
votes
0answers
18 views

Inline Ajax call after term is appended with a @ or # etc. displayed in div

Basically what I would like to know is how to do the following: I have TinyMCE Advanced enabled. I would like for my users to be able to tag content with different special characters (each refer to a ...
0
votes
0answers
30 views

Nested get_template_part / WP_Query – How should I do this?

I'm running a loop that runs a certain get_template_part, and that template file itself should then run another get_template_part, with the purpose to get some posts, is this even possible? At the ...
0
votes
1answer
26 views

Comparing 2 Decimal Numbers from custom fields and displaying posts

This is really confusing me. Hopefully you can help me. What i want to do, is search for a number and display anything that is either minus 1 or plus one of the search result. The numbers that it will ...
0
votes
1answer
72 views

Display custom field meta outside loop, site wide

I've created a custom field ("breaking") with the goal that whenever one post has this field present, it will display the value in the header throughout the site (that is, all posts, pages, archives, ...
0
votes
1answer
29 views

List ALL posts within last week from current category on category page

My category template shows 5 (full content) posts per page and I want to add a list of ALL the posts during the past week for that category to the top of the page as a quick overview. So the first ...
0
votes
1answer
41 views

Pagination in custom query in a category page

In a category (I create category-123.php), I'd like to create a new custom query in order to show all the posts that have right parameters (custom fields). <?php $today = date("Ymd"); $paged = ...
0
votes
0answers
53 views

WP_Query on “property” in the options table

I'm quite new to WP and I hope this question isn't seen as too specific. It's not entirely bound to my little "pre story". I'd really like an answer to this question for future cases as well. I get ...
0
votes
0answers
43 views

WP_Query Order by Specific Post ID First

I'm creating a website where I have a need to show a set of posts from a custom loop but I need to display a specific post first. This post will be dynamically specified in the URI by a $_GET ...
0
votes
1answer
29 views

Orderby two meta fields not working

Good day. I have the following code: $args = array( 'post_type' => 'property', 'tax_query' => array( array( 'taxonomy' => ...
0
votes
2answers
61 views

WP_Query displaying ALL posts

I cannot figure out why my WP_Query always displays all my published posts regardless of what I put in the arguments. <?php $args = array('numberposts' => 1, ...
0
votes
1answer
52 views

wp_query args adding muitiple tax_querys

i am creating a custom search system which search my custom post type recipes, in the search it searches the taxonomies terms that people have selected. Now due to the way it can hard code all these ...
0
votes
1answer
58 views

Removing posts from the returned wp_query. Cannot use object of type WP_Query as array

My end goal is to perform 3 custom field filters on a sets of filters on a WP_Query. The difficulty arises as I need to use both AND/OR relations between the 3 filters: field1 = A AND field2 = ...
0
votes
2answers
80 views

WP_query orderby not working after WP4.0 update [closed]

On my Wordpress-website, I have a custom post type used to display events and a page showing all events in the database. On that page, I'm creating a new WP_Query and displaying the results ...
-1
votes
1answer
43 views

Enter a variable in the 'category_name' parameter

Is it possible to use a variable for the 'category_name' parameter? I have three pages: red, yellow, and blue. I have multiple posts that are categorized in three categories: red, yellow, and blue. ...
0
votes
2answers
18 views

Do not show children of a category

I'm trying the next code: $categoria = get_the_category(); $hijosCategoria = (array) get_term_children($categoria[0]->term_id, 'category'); $queryBase = ...
0
votes
0answers
41 views

Add different classes and use different image size on every nth post in loop

I'm creating a new site for a client and they want to have a Masonry style layout for the homepage with 3 different image & width sizes. The default class is "medium-3 small-square" but what I ...
3
votes
1answer
135 views

In loop: posts have thumbnail AND other variables

I am looking to display posts that meet certain requirements. First and foremost, the idea is to show visitors the most viewed posts. I implemented that with some help. So, I got that working with the ...
0
votes
2answers
83 views

How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code... global $wpdb; $findID = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = ...
0
votes
2answers
25 views

How to dynamically attach pictures to a carousel

I am trying to make single pages for each individual portfolio piece. I created custom posts & field types, but it only seems to allow one featured picture per post. Should I be adding my pictures ...
0
votes
0answers
20 views

Wordpress MySQL query to add multiple users with related article

What I need is to add 100 users to wordpress and each one should have one post assigned to him, like a profile page (I don't want to use the default wordpress profiles because in the feature each user ...
0
votes
1answer
23 views

Return a single custom post from multiple meta queries

I'm currently working on a widget which returns a single random featured property on a website but I'm having some trouble with my WP_Query arguments. In the backend I have 2 checkbox meta fields ...
0
votes
2answers
53 views

Carousel Loop only duplicating

I have problem with looping and WP_Query. Any idea how i can implement the multiple carouselitems please check what html output should be in html So basically one of my goal is each div have a pages ...
0
votes
1answer
24 views

Custom query to order by multiple taxonomies

I got this website from a customer to fix some bugs. They are a car dealership. The previous developer created a custom post type (vehicle) and there are two taxonomies: make and model. (they are not ...
1
vote
3answers
50 views

Categorising search results based on Custom Fields

I have two sets of posts - some have a Custom Field (true/false). So the ones which have a Custom Field (for this, let's just call it custom_field) value of true, go in one set, and the others (the ...
0
votes
0answers
69 views

Wordpress WP_Query Array Custom search via taxonomies

Im trying to write a custom search function for my wordpress site. Im using WP_Query and multiple arraylists. Is it possible to order by search after taxonomy = pa_felg-bredde ? Here is my code so ...
0
votes
1answer
26 views

Exclude categories from search query

I have two categories that I want to exclude from my search results, so far without luck. I have tried adding the following piece of code but it didn't work. $search_query = ...
0
votes
1answer
27 views

Orderby custom meta returns random order

[Answered by Roberthue - I was sorting by meta_value instead of meta_value_num] I've created a WP_Query that does the following: Grabs a list of businesses for sale Orders them by a meta query, ...
1
vote
2answers
48 views

Fetch posts from current week (Sunday to Saturday)

I'm trying to fetch posts from current week. <?php $args = array( 'date_query' => array( array( 'year' => date( 'Y' ), 'week' => ...
0
votes
0answers
31 views

How to show 4 previous posts from current article category in Wordpress?

How to show the 4 previous articles on Single Post (single.php), only from current article category? Also if no previous article found, loop from the next articles. Please no plugins... I need to ...
0
votes
1answer
51 views

Post data in separate divs with incrementing class using WP_Query

I'm trying to achieve this result (which is the static HTML) and this is what I've gotten so far. Below is the approach I've taken: Created a CPT for 'locations' Created a custom taxonomy 'region' ...
0
votes
1answer
29 views

ordering and optimizing functions

Ive been hard at work trying to build some functions to display products on my site. The prices for these products are calculated based on many variables. I think the first set of functions work, ...
0
votes
0answers
69 views

Add input fields to Wordpress search to search custom fields

I have 2 custom fields: first and last. My goal is to add 2 new input fields (first and last) to search their respectable custom field. Here's my form code in searchform.php: <form role="search" ...
2
votes
2answers
111 views

Where to use $post global variable?

I am confusing to use $post global variable. Is it use inside loop or outside loop? What is the advantage to use it inside and outside loop?
0
votes
0answers
18 views

Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?

I have the following problem with featured tag posts I have a page of a website in wich I want to show only the posts that have setted a specific tag (using the loop). So in this page I have put ...
0
votes
0answers
13 views

Why I have this strange behavior when I try to exlude the featured post from posts visualization?

I am quite new to WordPress theme development and I have a strange behavior with this custom theme on which I am working: http://lnx.asper-eritrea.com/ As you can see in the home page I have 2 areas ...
0
votes
1answer
89 views

Selecting posts older than the current Unix epoch timestamp

I am trying to perform the following query, which originates by the fact the post's 'date' and 'time' are entered as separate custom fields. $args = array( 'post_type' => ...
0
votes
2answers
72 views

Filtering WP_Query result by category

Using WP_Query, I need to gather a selection of posts that are both Category1 and Category2. I want this selection to include Category1 and all of its subcategories (Category3 and Category4), as long ...
1
vote
2answers
40 views

How to use an associative array in post__in with WP_Query?

I have stored user favorite posts in the user_meta table of WordPress. The data is stored in a format, for example a:1:{s:8:"post-134";s:3:"134";s:8:"post-136";s:3:"136";}. How can I get this in the ...
0
votes
2answers
30 views

Post archive for certain post format

I am using the following code for a custom archive of all posts: $taxonomy = 'category'; $param_type = 'category__in'; $term_args = array( 'orderby' => 'slug', 'order' => 'ASC' ); ...
0
votes
0answers
29 views

Querying and Ordering Hierachical data

I am developing a WordPress site that requires the display of song lyrics. Here's the archive data that needs to be displayed: [Released 2014] - Album Title [Track 1] - Song Title [Track ...
9
votes
1answer
569 views

Why is the loop not empty on some 404s?

I came across a weird issue. Say you access a random url, three or more levels deep: http://example.com/a/b/c http://example.com/a/b/c/d ... Then is_404() is true. So far so good. But for some ...
2
votes
1answer
55 views

Is “orderby” in WP Meta Query conflicting with Meta Query?

I'm trying to write a meta query that looks for either events starting within the next year (event_start_date between now and 52 weeks), or events that are still going on (event_end_date between now ...