"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.
3
votes
1answer
207 views
WP_Query ignores post_type in category view
I have following query to select posts by my custom post-type. This works fine while being on the frontpage (the snippet is included in the sidebar). As soon it gets executed on a category page the ...
3
votes
1answer
125 views
How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
I added the following to my functions.php:
add_action('pre_get_posts', 'keyl_get_emp_posts');
function keyl_get_emp_posts($query) {
if ($query->is_main_query())
...
2
votes
1answer
206 views
Using is_main_query to select custom post type on certain page
I've been trying to implement some of the ideas discussed by Andrew Nacin http://wordpress.tv/2012/06/15/andrew-nacin-wp_query/ into my workflow, specifically trying to move away from using ...
2
votes
1answer
108 views
$wp_query meta_key naming issue
What I am attempting to do is sort posts by custom fields.
I have a few custom fields that don't query properly and I get the 404 page. The fields that don't work I used hyphens in the naming ...
2
votes
1answer
202 views
Excluding a custom taxonomy term breaks wp_get_post_terms
I'm trying to exclude one custom taxonomy from an archive page, and then show the terms of the returned posts.
When I run WP_Query to exclude the custom term, it returns the posts correctly, but no ...
2
votes
1answer
75 views
match 2 posts on categories
I have blog posts each having 3 or more categories.
The issue is that i need to search related posts to a post and i have to match at least 2 categories i.e. there must be 2 common categories. I am ...
1
vote
1answer
58 views
Gravity Forms field entries into wp_query loop
I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)...
add_action("gform_after_submission_18", "set_post_content", 10, ...
1
vote
1answer
40 views
Query Posts With Over 1000 Views
The code below is from this link. It basically creates a hit counter, but I'm probably gonna have to do this by IP.
How do I make a WP_Query, where only posts up to 1000 views can be seen on the ...
1
vote
1answer
35 views
How to combine custom fields to make one order-able value
I have three different custom fields, for day (01-07) hour (01-12) and minute (00-59) and I really need to combine them into one custom value so I can actually order them using wp_query.
I cant ...
1
vote
1answer
129 views
WP_Query orderby breaks when using AJAX?
I'm running in to a bit of a problem.
I have a function called get_press(), it retrieves newest press items. It is inside of a plugin:
class EWPress {
function __construct()
{
...
1
vote
1answer
90 views
Retreaving all images attached to current post
I am trying to retrieve attachments that are attached to my current post. This is the code that I am trying to use. What I'm attempting to do is query all of my posts that are of custom post type ...
1
vote
1answer
249 views
Get posts with tag all post types
I'm trying to get all posts that have a specific tag, regardless of what type of post that is. I've tried every solution I've found (here on SO and further), but nothing works: I always only get the ...
1
vote
1answer
44 views
change recent posts based on category
I am writing a code to display the recent posts of different categories. On clicking category 1, I want to display the recent posts from cat1 and on clicking cat 2 the recent posts from cat2 and so ...
1
vote
1answer
150 views
WP_Query - filter by multiple meta values and order by other meta values
I'm trying to query posts using WP_Query and meta_query parameters:
$args = array(
'post_type' => 'produkty',
'meta_query' => array(
'relation' => 'AND',
...
1
vote
1answer
49 views
How to list posts with disabled/closed comments, with pagination?
i'm interested how to display all posts (from all categories) that have closed/disabled comments?
I have tried using the comments_open() function inside the loop, that works, i don't know how to ...
1
vote
1answer
77 views
Query Page Content From Theme Options?
I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme
That lists the pages in ...
1
vote
1answer
91 views
posts_per_page option limits the number of Gallery items
I have noticed that if I have a query where posts_per_page are set to 4, any (image) gallery that belongs to one of those posts will too have only 4 items (although when I create the gallery from Add ...
1
vote
1answer
1k views
How do I use wp_query for WordPress search?
I would like to create a custom search form to search posts based on the values of about 4 custom fields. I tried using wp_query to achieve this but so far my biggest problem is that the I don't get ...
0
votes
1answer
18 views
displaying a fall back query if there's nothing in the post-type category
I'm stuck trying to figure out the best way to manipulate my query so that if there's nothing in the category it will display the latest post-type.
Here is the query I've got that pulls in the posts ...
0
votes
1answer
7 views
Pull Instagram images into an existing loop?
I am looking for a solution to pull Instagram images (from a single account) into a Wordpress loop and mix them chronologically with standard posts that will have been created within the Wordpress ...
0
votes
1answer
27 views
Get Posts in a Custom Post Type category
I have trouble in getting post in a custom post type category. I have code below but it doesnt work well. It still get posts in another category.
<?php
$query= null;
$paged = ...
0
votes
1answer
76 views
wp-query Shortcode in Gravity Forms Notification
I have the following code that runs two wp-query loops upon form submission to display specific posts depending on the users choices in the form (The form fields are radio buttons with values that ...
0
votes
1answer
38 views
Can you order posts from wp_query by two custom meta fields?
I'm working on a site that lists events. Right now this query lists events by date:
$args = array(
'post_type' => 'espresso_event',
'post_status' => ...
0
votes
1answer
38 views
404 on Pages for Custom Post Type & Query_Posts
It took me quite a while to find a good solution for ordering a custom post type by two custom meta keys. When I finally got it working, I found out the pagination no longer works. I've tried dozens ...
0
votes
1answer
38 views
WP Paginate not working properly
Im creating a WP for a custom type post in a page template:
<?
global $paged;
global $notquery;
$temp = $notquery;
$notquery = ...
0
votes
1answer
42 views
What is wrong with this wp_query?
I need to query posts by two meta fields and the wo_query I'm doing it with is returning nothing. Obviously, it's broken. Can somebody tell me what I'm doing wrong?
$args = array(
...
0
votes
1answer
35 views
Custom loop won't work, can't find problem
I can't figure out why this custom loop isn't displaying for me:. I've tried removing the if statement and removing certain query parameters but it just won't display. If I delete the loop entirely ...
0
votes
1answer
53 views
How to extract images of post and pages excluding header and logo image in wordpress?
I have tried this code to get all images from media library and i am sucessfully getting the source urls of all the images but now i want to exclude all the unwanted images like logo, header images ...
0
votes
1answer
49 views
Custom loop of a single category, cannot order by date. What am I missing?
I'm going nuts.
All I have is a simple loop on the home page of the site (which is a static page), and it should show the most recent (1) post of a certain category. The trouble is no matter what i ...
0
votes
0answers
38 views
No results for my WP_Query array
I have to get related posts via keywords/tags, and I found a ton of examples elsewhere on how to do it, but the query doesn't seem to produce any results. Can anyone point out how to do this, and is ...
0
votes
0answers
105 views
Some filter adding custom post types to my WP_Query
I have a strange problem. I am using WP_Query inside a shortcode callback. Say I have 10 custom post types and I want to show the most recent post from 4 of them. I specify them as
'post_type' => ...
0
votes
0answers
83 views
previous_posts_link works, but next_posts_link doesn't
I have a template with a custom wp_query. I need to add navigation links to the query. No matter what page I'm on, I can't get the next_posts_link to appear. The previous_posts_link works just ...
0
votes
0answers
36 views
WP_Query - How to show last post from each meta value
I have a custom post type where I have testimonials which are all grouped by 6 industries (meta value).
On the post type archive page I would need to show the last testimonial from each of the 6 ...
0
votes
0answers
69 views
Fatal error: Allowed memory size of 37748736 bytes exhausted …, on larger offset query parameter
I hope this is not a duplicate question.
I have a custom .csv generator functions that basically export data from posts and its post metas.
The function works fine on this WP_query parameter:
...
0
votes
0answers
17 views
Sidebar IF query hiding everything
I have this query which I'm using in the sidebar, but when I place it in a php widget, the whole sidebar disappears... The code is below and the full sidebar code is in a pastebin here ...
0
votes
0answers
38 views
override “cat” parameter using pre_get_posts
There's this query:
new WP_Query('post_type=post&posts_per_page=3&orderby=date&cat=10' );
I'm using pre_get_posts hook to modify the query and it's working fine for different parameters ...
0
votes
0answers
97 views
Custom post types and custom taxonomy posts are not showing
I have got a post type set up called 'shops', attached to this is a taxonomy called 'Types'.
When you search through each category in the category menu it looks for the posts and displays them in a ...
0
votes
0answers
17 views
Sidebar If Query
I have this query which I'm using in the sidebar, but when I place it in a php widget, the whole sidebar disappears... Any ideas?
global $wp_query;
$postid = $wp_query->post->ID;
if ( ! empty( ...
0
votes
0answers
36 views
WordPress forcing menu_order in custom post type sort
For some reason, my custom post types are not ordering any more. I don't know if it's 3.5.1 issue or something else, but it was working fine and nothing changed. But suddenly, they have stopped ...
0
votes
0answers
14 views
Altering query to return more data
I am building a web app with WordPress. I have a situation where every time I do a while ($query->have_posts()), I immediately do a get_field('due_date'). I'm using advanced custom fields. This ...
0
votes
0answers
204 views
Loading content dynamically using jQuery.load
So I am working on a website for a client and they want a tabbed content area. Without loading all of the queries on a single page, how can I go about doing this? Right now I have the following for my ...
0
votes
0answers
36 views
posts_per_page is set to 1, returns 50 posts
I'm trying to get the latest post in a custom post type:
$query = new WP_Query(array(
'post_type' => 'some_custom_post_type',
'posts_per_page' => 1,
'orderby' ...
0
votes
0answers
67 views
paginate_links using wp_query post_per_page value?
Wondering if its possible to control the paginate_links count on a content basis without using some type of functions.php edit?
Essentially I'm running a wp_query that has a 'post_per_page' parameter ...
0
votes
0answers
39 views
WP_Query returns 100 results on homepage
Bit of a strange one this...
I've recently migrated a site from wordpress.com to my own server. In the new location, however, wp_query always returns 100 posts on the homepage, regardless of which ...
0
votes
0answers
32 views
Retrieving Categories of posts which have a custom Taxonomy
I am working on an event management WordPress site which has multiple taxonomies (Photographer, Event Manager, Decor, etc).
I want to create Taxonomy pages for each of these taxonomy (this is the ...
0
votes
0answers
52 views
Complicated Custom Post Type Query drill down, using meta query
I currently have defined a few custom post types.
a product category size
a product category
a product.
Inside my product, I hold and save meta data on a dropdown list of product categories. So ...
-1
votes
0answers
36 views
List custom post type URLs based on user form selection
I'd like to set up a form with dynamically populated radio buttons for all custom post types. Something like this:
custom post type 1
custom post type 2
custom post type 3
continued for all CTPs...
...
-2
votes
0answers
30 views
Get all posts starting with first two letters in Wordpress
I have a plugin in which an alphabetical list is posted where people can click on a letter and they get the posts with that letter. So if they click on A, they see all post titles starting with the ...
-2
votes
0answers
17 views
Problem with Creating a Custom Select Query with Custom Post Types
I am facing problem to join two tables one is wp_posts and another is wp_like_dislike_counters this table is created by using a plugin.
So i want to show all the posts which is liked by a user in a ...
-3
votes
0answers
29 views
Pagination Issues
I've got a static home page with a wp_query for custom post type posts that need to be paginated. I'm using a page builder plugin to build the rest of the page.
I'm using the following code but the ...
