"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
24 views
Query for first 3 posts to change the look and feel
Is there a way to query for the first three recent posts and then change how they display on the front page?
I want the first three posts of my blog to show differently than the rest of them i.e. ...
0
votes
0answers
15 views
Pagination won't go to page 2 [duplicate]
I've created a page which uses posts 2 posts and pagination
The pagination will not go to page 2, every time I click the link it reloads the page, however hovering over the page two link shows the ...
0
votes
2answers
218 views
Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
I am trying to display 3 post_thumbnails from a custom post type "portfolio" on my homepage template. So one from post 'A' , one from post 'B' and one from post 'C' The image from post A will be set ...
0
votes
1answer
105 views
Search.php - return number of results but cannot loop through
I have a following search.php page (this is just the code required for problem presentation).
Why is my $total_results returning a number of posts found, but when I do a loop though it always print ...
0
votes
1answer
202 views
wp list pages using meta box value
I am using following meta boxes on services page but how i get page which on meta box value...
for example list all pages where service_type = 'web'
I am using following now...
<?php ...
0
votes
1answer
185 views
WP_QUERY tax_query not working
$query_args = array(
'cat' => $lesson_id,
'meta_value' => $lesson_type,
'post__not_in' => array($current_post_id),
'tax_query' => array(
array(
...
0
votes
1answer
19 views
Query posts by Author and/or by Tag
I'm pretty sure I need to do some sort of custom query, but not sure about the best way to go with it.
I have an author page. It needs to display that author's posts. That's fine, I can do that. I ...
0
votes
0answers
26 views
Doesn´t get right information from wp_Query in wordpress using Easy Content Types
Have problems to sort out right information using WP_Query together with Easy Content Types. My query looks like this
<?php
$query = new WP_Query( array( 'post_type' => 'buildarea', ...
0
votes
1answer
32 views
querying on custom meta fields and sorting them by custom meta
I have event posts with multiple custom date and time fields.
To pull all the events happening this week, I am querying on the different date fields.
Here is my code:
$today=date("Y-m-d");
$nextweek= ...
0
votes
2answers
264 views
How do I Use Multiple Loops with WP_Query?
Hi I am trying to add post from a certain taxonomy term to a cpt loop. The code below is the code I am using.
<?php // Create empty array to store post ids in
$excludes = array();
...
2
votes
0answers
32 views
How to implement time filter to show random post 1 month for one category and 3 months for other categories
I started to work on one website after another developer and there is problem with his "popular widget" which is basically showing 3 random posts from category. There is some Switch statement which is ...
0
votes
1answer
15 views
Displaying content to search engines but via navigation only for registered users.
Displaying certain information depending on if a user is registered is quite easy as I have been using this code
<?php if (current_user_can(‘subscriber’)) { ?>
[content here]
<?php } ...
-1
votes
1answer
25 views
query posts in wordpress
I want to filter my query results just before the_loop starts in word press. I only want the results having term_id or term_taxonomy_id equal to 1.
...
0
votes
2answers
41 views
How to output comments number of a post per day?
I have a question about the comment numbers in a post... For now, I can output the total number of a comment inside a post outside the loop. That's cool enough, but I want to get show the comment ...
2
votes
2answers
128 views
What is an efficient way to query based on post_meta?
The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a ...
1
vote
4answers
164 views
WP_Query returns no results
I'm using wp_query to create a custom query that retrieves search results but it is returning 0 results. Here is the code:
$query = 's=the&posts_per_page=5&paged=1';
$custom_query = new ...
0
votes
2answers
76 views
Search Page Returns Nothing
I'm currently working on this website and a test shows that the search page isn't working properly. Every time someone searches for something, it comes up blank. The code for the search page is as ...
0
votes
1answer
9 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 ...
1
vote
1answer
38 views
WP_query posts closest to todays date
I have written an wp query which I would like to order in a bit of a complicated way. Some posts have a meta value 'the_date' which is an end date for the post. I would like to order posts in date and ...
0
votes
1answer
22 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
0answers
30 views
Advise on Templates for Custom Queries
I'm trying to figure out the best way to solve this problem. I have a couple of archive type pages that display content from multiple post types at once. For example, I've overridden the default ...
0
votes
0answers
15 views
Wordpress $wpdb->query() inserts multiple rows with duplicate data
I am experiencing very strange problem with wordpress query() function.
I have a form on page 1 where below code to insert a new record.
if(isset($_POST["transaction_id"])){
global $wpdb;
...
0
votes
4answers
622 views
Why does “Blog pages show at most” interfere with my custom wp_query?
I'm very new to WordPress, especially when it comes to creating a custom loop as per below. This works fine, however I'm perplexed why "Blog pages show at most" (under Settings > Reading) is ...
0
votes
0answers
25 views
Create args for WP_Query using infinite scroll
I'm trying to use infinite scroll in my page as below.
http://phototravel.flop.jp/category/japan/mothersfarm/
All photos are actually custom posts under a category. It's using jquery masonry layout.
...
0
votes
1answer
117 views
WP_Query do not include posts with a certain value in a custom field -
I am trying to grab the 5 most recent posts and have it exclude posts in an array that is already defined ($exclude), sticky posts and any posts that are checked off as a featured post (i.e. with the ...
0
votes
1answer
49 views
Custom query with category exclusion and post-meta “whitelist”
I have two widgets, one shows News while the other shows everything except News (We'll call the second one Blog). The blog portion is currently working correctly.
The News posts are either ...
0
votes
1answer
199 views
WP_Query not retrieving by random order under parent
I currently have TWO subpages under parent page ID 43. Client testimonials.. Anyway. I have the random order thing in the query $args but the order never changes. What could I be missing?
...
0
votes
0answers
27 views
Reduce number of SQL queries inside WP_Query loop to fetch author data
This question applies to scale and does not concern typical blog implementations. I'm working on a web app where I'm running standard WP_Query to fetch some custom post types. This usually results in ...
0
votes
2answers
123 views
How to get only ONE category of “Portfolio” posts to display on main page rather than ALL categories?
I have a section on my main page that displays a new “Portfolio” post each time I write one no matter what category I assign them to. What I want to do is make the main page only display one specific ...
2
votes
1answer
221 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 ...
0
votes
1answer
130 views
Converting multiple loops into one single loop with pagination
I am using Isotope jquery plugin to filter/sort posts in Wordpress but to correctly filter the posts into the right order I have needed to output each category one after the other. To do this I've ...
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 ...
3
votes
1answer
127 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())
...
0
votes
0answers
20 views
Complex WP_Query Using Post Date And Post Meta
I am using Wordpress as a CMS on a website which has standard posts, a custom advert post type and a custom event post type. The event post type has some custom meta which stores the event start date.
...
0
votes
1answer
46 views
Count posts returned by get_posts in external PHP script
I'm using WP from an external PHP script by including the wp-load.php file.
All functions and everything works as expected so far, except one thing: I can't get the $wp_query->found_posts to work ...
0
votes
0answers
27 views
Search with meta_query and tax_query
I'm working on a little database for series based on wordpress. I've implemented a custom post type called "anime", some taxonomies (Genre, a_types..) and a lof of customfields. (based on acf). Now ...
0
votes
2answers
33 views
Set conditional on template based on referring page slug
I have a portion of a page template that is conditional upon the following elseif
<?php elseif( isset( $wp_query->query_vars['details'] ) && $wp_query->query_vars['details'] == ...
0
votes
1answer
342 views
Query Custom Post Type by Taxonomy
I've created a query working fine pulling posts from a specific taxonomy—but before I had only 7 taxonomies that were permanent, now I have sub taxonomies under that main taxonomy and they will be ...
0
votes
0answers
16 views
When importing a database any page with a wp_query in doesn't work
I've noticed this a lot, when I export a database from a test site and import it into a live site, any (or most) page with a wp_query in it doesn't show up correctly (It shows the theme, but as though ...
0
votes
2answers
46 views
How should I approach changing the template & $query as part of a shortcode's execution?
I am working on a project where I need to be able to change the template being used if a given shortcode is used. To complicate things more, the plugin must also be able to rewrite $query if this same ...
1
vote
2answers
369 views
Get list of months with posts
I am trying to add a filter on my custom theme based on post month, similar with the archives but with some differences.
What is the best way to get a list of months in witch we have posts?
Thanks,
...
-2
votes
0answers
40 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 ...
0
votes
0answers
26 views
Custom WP_Query for WordPress Search Results with meta_query
I am using a custom query to generate my search results. The code I am using works perfectly without the meta_query variables in my arguments array.
I am trying to compare multiple custom fields with ...
1
vote
2answers
106 views
Query last updated posts (posts updated in the last 24 hours)
I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours.
My idea is to have a page of posts or perhaps on the index.php a lists of ...
0
votes
1answer
126 views
Pre_get_posts Gives 404 on Custom Post Type
I'm trying to filter the query on a sub page called "Ask Question" to list all of the recent questions submitted by users, but I get a 404 when going to the page. Flushing the permalink structure did ...
0
votes
2answers
137 views
Multiple Orderby's using random order WP_Query
Here is the setup.
The site in question is a website that displays listings. Each listing has a rank (1-3). Basically it's a listing type... small, medium & large to determine how much the ...
0
votes
0answers
31 views
Multiple homepage layouts as selected by user from theme options
I am working on a theme which will enable users to select multiple layouts from the theme options panel.
What I did so far is to create multiple theme files, depending on each theme, put it in a ...
0
votes
1answer
113 views
Select custom posts by meta_value and sort by a different meta value
I have my query set up like this:
$article_query = new WP_Query(array(
'meta_key' => 'issue',
'meta_value' => $post->ID ,
'post_type' => ...
2
votes
1answer
114 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 ...
0
votes
1answer
1k views
Show all products on one page with WooCommerce
I have WooCommerce running on this store.
Although the default is to show 12 products on a page the client has asked for a "show all" button that will prevent the user having to use pagination to get ...
