"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.
0
votes
1answer
68 views
Select from wp_post and multiple meta_value from wp_postmeta
My lack of SQL skills has stopped me in my tracks here.
I'm trying to select post_id, post_title and two postmeta values - the first has the meta_key of 'search_country' and the second a meta_key of ...
0
votes
1answer
36 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
0answers
41 views
Scheduled Post Meta Update in Wordpress
I have a system that sums up values from various sources and pass those to post_meta in order to query posts in accordance with the order of meta_value_num.
I was successful at passing those value to ...
0
votes
0answers
85 views
custom Wp_Query / permalink + wp_pagenavi = not working
Testing it in my WAMP environment (with default permalinks), next/previous/page number(s) (links) pulls up the appropriate information - pushing it to live with a custom permalink structure results in ...
1
vote
2answers
67 views
Query for posts in 2 taxonomies
I am currently using the following code to display a list with links to posts in a specific CPT and taxonomy:
<?php
$custom_terms = get_terms('videoscategory');
foreach(array($custom_terms as ...
0
votes
0answers
39 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
1answer
75 views
Posts of specific category on page and excluded from index.htm
hope things are going well.
I'm trying to create a member's only section specific for posts of about job opportunities. My goal is to have posts of this category displayed on this page and excluded ...
0
votes
1answer
49 views
wp_query select if have comments
I previously asked and accepted a similar question here:
wp_query and comment_parent - select only posts with top level comments
So I'm trying to use wp_query to select only posts that have comments. ...
0
votes
0answers
120 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' => ...
1
vote
1answer
65 views
When tax_query used, results disappear (0 =1 produced)
I'm trying to perform a dynamic query that uses a dynamically passed taxonomy and post_type, and displays results accordingly —
A user makes a selection from 3 drop-downs on a form, each have a ...
0
votes
0answers
85 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
1answer
57 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
2answers
33 views
How to find what index page a post is on?
Here is a simple example of what I am wanting to figure out.
Say I have WordPress set to show 5 posts per page. And say I there is a post 17 posts back chronologically.
The formula would be 17 / 5 ...
0
votes
1answer
179 views
Custom post-type's pagination not working in category.php
I have this code to the file category.php :
<?php get_header(); ?>
<div id="content">
<div id="all">
<div id="todo">
<?php
$my_query = null;
$paged = ...
1
vote
0answers
26 views
Meta Query And/Or
My question is very similar to Meta Query with AND & OR? . This question was answered in 2011 by @Otto.
With the exception that my logic is different.
I want to query, for example, posts with ...
0
votes
1answer
23 views
Custom query shows custom post types in trash
I have a custom wordpress query like so:
$query = new WP_Query(array('post_status' => 'future || publish', 'post_type' => 'kalender', 'order' => 'ASC'));
But the problem is that the items ...
0
votes
2answers
68 views
Create a Blog Template Page
I am trying to create a template that will display a list posts of a specific custom type. However, I am missing something fundamental. So far, here is what I have:
functions.php
add_action( ...
1
vote
2answers
55 views
Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
I am literally clueless as to why the code does not function properly on the first page, but functions as expected on the second page. I have already tried running the second query via another ...
0
votes
0answers
37 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
1answer
82 views
filter posts by meta key with pagination
Trying to filter out specific posts that have certain meta_key from the main query... problem is it doesnt work with pagination which is my issue here.
Anyone knows how to solve this?
$paged = (end( ...
0
votes
0answers
71 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
2answers
50 views
Post Type => Any conundrum
I have a number of regular posts and pages in a regular category called "Featured". I have also installed a plugin called "Event Organizer" that creates its own custom post type called "Event" and has ...
0
votes
0answers
39 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 ...
4
votes
1answer
112 views
How can I save an array from a random post sequence for later use?
I'm building a random workout generator on Wordpress to help with my fitness, and am stuck at saving random post arrays for later reference.
I'll explain.
The generator should work in two main ...
0
votes
1answer
52 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
1answer
36 views
Dynamically change post_parent in every page load?
What's the correct Wordpress action where I can hook to dynamically change the post_parent of a post? I understand that a post can't have multiple parents so that's the only way I can think of to ...
0
votes
1answer
61 views
Query specific number of posts for each post type in specific order
This is related to this other question, I tried with get_posts, pre_get_posts, WP_Query and basically every option I could find for 2 days now, no solution yet.
The full problem in hand: I have 2 ...
0
votes
1answer
29 views
Determining what post is displayed out of total posts found
On my page I've got a query that retrieves posts with specific parameters and I'm displaying one post per page with pagination. I've figured out how to get the total count of posts found by the query. ...
0
votes
1answer
115 views
WP the_posts() on single-cars.php get category link
I have a custom post type called cars.
There is a taxonomy brands.
I have a template single-cars.php and I'd like to add a link to the brand page(The category).
Assume I'm on the page of the post ...
0
votes
0answers
102 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 ...
1
vote
2answers
38 views
How to query different post types in specific order?
I have 3 posts types, articles, news and tips. On the home page I want to query 20 posts in this order:
article, article, news, news, tip, ...// same order again until 20
If I use a custom query ...
0
votes
1answer
94 views
Query Problem - Show posts within category 'x' that have a custom field between 'y' and 'z'
I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called ...
0
votes
1answer
19 views
Query by post type or category
I now that WP_Query can query by post_type and category but i need to get data from custom post type or from category which is standard post type. Adding category to my custom post type is not an ...
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
1answer
29 views
Modify query after meta value
I would like to change the calendar so it will display some posts based on a custom date field. For now i am interested to modify this query:
$wpdb->get_results("SELECT ID, post_title, ...
0
votes
1answer
41 views
Specify strict 'order by' in WordPress query
I have a custom post type called Employees where an employee's name is the post_title of each post.
I am trying to figure out how I would sort the post_title column by last name.
So for instance, if ...
0
votes
0answers
38 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
10 views
Making $paged work with WP_Query [duplicate]
I've created a page that displays posts of a certain category from a custom post type but I can not get the paging to work. I've tried to use this as a guide but I don't understand what I am doing ...
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 ...
4
votes
2answers
226 views
Query Posts by Custom Field 'Price'
I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called ...
0
votes
1answer
135 views
Upcoming Event: How do I sort database by custom date field, but ignore past dates?
I am using an events plugin and struggling to get my database query to be perfect. The query is on the event-single.php template. What I need the query to do:
Query the "events" custom post type ...
0
votes
1answer
122 views
post__not_in not working for custom post type [closed]
I cannot get the 'post__not_in' parameter to work properly in my theme. I have a custom post type 'event'. I'm in this theme file: single-event.php
<?php $args = array(
'post__not_in' => ...
0
votes
1answer
155 views
Custom Search Result Page displaying only 1 result.
I'm trying to build a custom search results page. The problem I'm running into is that when I enter a search term ; say 'gaming', it will only return one result, being the latest result. I have my ...
1
vote
2answers
138 views
WP_Query or get_posts?
When using the 'fields' => 'ids' parameter, is it better to create a new WP_Query in the code below rather than doing get_posts?
How would the loop look if I used WP_Query?
function ...
1
vote
1answer
155 views
Display all posts for taxonomy term across multiple custom post types
I'm currently creating a website that uses several content types, (e.g. books, movies, shows) as well as a key taxonomy term (e.g. status, with values of owned and wishlist).
My question is, in a ...
0
votes
1answer
402 views
All-in-One Event Calendar: Custom Query - Getting each event Instance
I am using the All-in-One Event Calendar by Timely, and I would like to display upcoming events from the events calendar in a carousel on a separate page, and I need to get the event information.
I ...
0
votes
0answers
219 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
3answers
76 views
Show only one category in main query, issues on tag page
I altered the following code from Ashfame:
add_action('pre_get_posts', 'block_cat_query' );
function block_cat_query() {
global $wp_query;
if( is_home() || is_search() || is_tag() ) {
...
1
vote
2answers
169 views
Wp_query: sort by PHP variable
Here is my problem:
For my articles, I use a custom post type "exhibitions" and posts for all other news. I am displaying them in one query ['post_type' = array('exhibitions','posts')].
The orderby ...