"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.
1
vote
1answer
115 views
recent posts for different categories
I'm developing a theme that will have two recent posts section on the home page- one section for recent portfolio updates and the other for recent blog posts. I'm struggling with implementing these ...
0
votes
1answer
602 views
Conditional arguments for WP_Query and tax_query depending on if $somevar has a value
I've created a new query for a custom post type of 'courses'. Those results are then to be filtered using tax_query, querying 3 custom taxonomies matching 1 or several term ID's. These are passed from ...
-2
votes
2answers
163 views
Query page: preserve page formating
dose anyone know how to get this query (or a different query) to preserve the page formatting?
Thanks
<?php
$my_postid = 663;//This is page id or post id
$content_post = get_post($my_postid);
...
1
vote
1answer
298 views
Compare post-IDs within WP_Query? (Less than / Greater than)
Can I use WP_Query to only query posts less than (or greater than) a given post ID?
$filtered_query_args = array(
'post_type' => 'projects',
'order' => $prev_next=='next' ? 'DESC' : ...
0
votes
2answers
148 views
Custom Query Fields - Altering Meta Value
I'm giving Custom Query Fields a shot for filtering/sorting posts on the front-end of a site. The instructions seem pretty self-explanatory, but I do have another layer that I'm trying to figure out.
...
0
votes
2answers
357 views
How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
I am using the Starker Theme as a foundation to build my custom WordPress theme. The Starker Theme comes with a loop.php file for setting up the main loop. I decided to use the loop.php file to ...
0
votes
1answer
163 views
How to display the 5 latest post titles but allow only 1 in there of a specific category
The question probably needs some clarification so here I go:
I'm building a carousel displaying the titles of the 5 latest articles.
However, from a specific category (called schaft in my case) it ...
0
votes
1answer
856 views
Can i merge 2 new WP_Query($variable) 's?
I am running a multisite network and i have setup a sql query that uses swith_to_blog(); and queries the posts.
Is there a way that i can declare the query inside a new WP_Query and actually merge ...
0
votes
1answer
97 views
Exclude All Posts Which Do Not Have A Tag Assigned
Basically I have regular Category Listings that include posts WITH tags and posts WITHOUT tags.
I need to modify the loop so that it ONLY includes posts which have one or more tags assigned to them.
...
0
votes
2answers
207 views
Disable (or limit) queries when certain content (or data) is not needed (or showed)
Currently I am making a custom design for a site. The problem I'm seeing in Wordpress is about almost all data pulled out from the database.
While in certain pages - like front-page.php - it only ...
2
votes
2answers
210 views
How to order posts tag by tag?
I want to order my posts by tags with only one WP_Query()
In my WP_Query I would like to display
2 posts with tags portrait
2 posts with tags paysage
2 posts with tags portrait
2 posts with tags ...
0
votes
1answer
504 views
Custom Post Type “property” (wp-property plugin) query issues
I've got wp-property plugin installed, and I am trying to have a custom query, to retrieve data from the database. If I query posts from other post_type is ok, but when I try to query posts from the ...
0
votes
1answer
791 views
Issue with front page navigation after upgrading to 3.4
I upgraded to WordPress 3.4 and am having an issues with showing a different amount of post on the first page versus the rest. The first page is still showing 5 posts but when I go to /page/2/ I'm ...
0
votes
1answer
331 views
Determining Author post count
This is more of an efficiency question as the following code does do what I want.
$user_name = get_the_authour;
$query = new WP_Query('author_name=JustinH');
$author_post_count = ...
0
votes
1answer
58 views
Change content off every sixth element
I would like to create custom post query where i will list all my posts in the list. Then the tricky bit is to add different content to sixth element off that list.
So something like this
...
0
votes
1answer
107 views
get_var is neither a string, integer, or array …?
$vote_count = $wpdb->get_var($wpdb->prepare("SELECT votes FROM wp_mytable WHERE product = %s AND
company = %s", $product, $company));
...
3
votes
1answer
131 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
1answer
159 views
Taxonomy order exception for specific term
I want to make an exception for my custom taxonomy order. Sometimes you need to put "Other" option as last option but when calling taxonomies with "orderby=name", sadly "Other" term is not listing as ...
2
votes
4answers
70 views
Get list of WP Updates Across Sites
Is there a way to query a WP site to see the number of updates currently available? I'm not really looking for a list of the actual updates, just the number. This would be the total number of ...
0
votes
1answer
541 views
How to make WP_Query not to show irrelevant posts?
I'm using the following WP_Query arguments array:
$args = array( 'post_type' => POST_TYPE,
'tax_query' => array(
'taxonomy' => ...
0
votes
1answer
920 views
Posts limit on homepage (genesis framework)
in home.php
// NOT working
query_posts('show_posts=3');
// NOT working
add_action( 'pre_get_posts', 'set_posts_per_page' );
function set_posts_per_page( $query ) {
$query->set( ...
1
vote
2answers
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
3answers
1k views
Query with pre_get_posts to get pagination
After pretty much getting everything working with query_posts, I noticed my pagination wasn't running. I was told pre_get_posts should be the solution.
My problems:
I don't know how to pass all my ...
0
votes
2answers
649 views
How to filter a static post page with ajax and $wp_query
I'm at a loss, I've found several unanswered questions related to this one. I have a static post page which has a search form in the sidebar. What I want to happen is to type in a keyword and then ...
0
votes
1answer
459 views
How to Loop within a Loop (Display Children and then Grandchildren)
I am trying to develop a query for WordPress that will allow me to display a list of child pages with titles only, and then under each child page title, a list of grandchilden (children of the child) ...
0
votes
1answer
614 views
Multiple post type queries (with specific arguments for each)
So i know how to combine post types into 1 loop and out put the loop. Below is what i have:
<?php
$args = array(
'post_type' => array('post','movie','actor'),
...
3
votes
2answers
396 views
WP_Query leaking absurd amounts of memory
Every time I call WP_Query() in the function below, Wordpress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly... :( I've tried unsetting the resulting ...
0
votes
1answer
245 views
Alter secondary loop to exclude posts from current page category
The below code is taken from sidebar.php where it outputs random posts from multiple categories and excludes the current post from showing up. This works great but how do I alter this loop to exclude ...
0
votes
2answers
195 views
Problem with wordpress pagination
First of all thank you everyone for all the knowledge base i got reading trough stackexchange. For the first time i couldn't find an answer to my problem.
The matter is that with this custom query ...
0
votes
1answer
1k views
Limiting the number of posts in WP_Query leads to unexpected result
The following is supposed to display 10 posts.
Sometimes it displays 11, sometimes 12, and sometimes the desired 10 posts. It behaves the same if I swap posts_per_page for showposts or numberposts .
...
1
vote
3answers
560 views
how does $wpdb differ to WP_Query?
I'm going to write a function to return the next/prev post in a specific category. can anyone tell me what the differences would be in using $wpdb as opposed to WP_Query(); eg new WP_Query(args)? what ...
10
votes
3answers
274 views
What is appropriate flow for custom data from URL in WP_Query?
I have multiple stage process that integrates complex faceting into WP queries. Problem is - the deeper I get the more fuzzy I become on how it is supposed to work and I could use a guideline rather ...
1
vote
2answers
114 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
2answers
86 views
Specific html within wordpress loop
I am trying to setup a wordpress slider, how can I achieve exact below result within a wordpress loop
<div id="carousel">
<img src="slide1.png" alt="" ...
1
vote
1answer
349 views
WP_Query display next custom post from today's date
I have a calendar plugin that uses custom posts types to create events. There are several custom fields that allow me to create various and seemingly unlimited post queries. The one I'm currently ...
0
votes
1answer
1k views
WP_Query with custom post type ID
This code isn't echoing out anything, even though I'm 100% positive $mixtape_id is set to an integer which corresponds to one of the posts within the 'mixtapes' custom post type
$query = new ...
0
votes
1answer
347 views
category__not_in and id values from variable
How can I set the values for category__not_in from two variables. On my example I just hardcode the ID of each category to exclude, but... how can I pass these values from some variables ?
...
0
votes
1answer
56 views
Help in query for list links
How to make one query for display a list of links like this:
Date 05/20/2012
Category - Link
Category - Link
Category - Link
Category - Link
Category - Link
Date 05/19/2012
Category - Link
Category ...
1
vote
4answers
569 views
Unable to display multiple post types in same query (WPML WP_Query)
I'm sure there's some very easy explaination for this, but I'm stuck. I am just trying to put a nice, simple recent posts element on the front-page of a site and for some reason when I try to use:
...
0
votes
1answer
493 views
Avoid WP_Query's duplicate posts with taxonomies
Given a blog featuring several categories (such as "Sport", "Nature", etc), I've then proceded to create a custom taxonomy, which allows me to show articles in certain areas of my blog with terms such ...
0
votes
1answer
951 views
Use the page slug in a WP_Query?
I'm doing some custom loops that I initialize with a query like this
$the_query = new WP_Query('page_id=266');
It works fine. It's just I'ld to call my page with its slug and not its ID.
Would it ...
0
votes
1answer
277 views
Meta query with timestamp using WP_query
I'm having a problem with an events system that I'm developing for a local roller derby leaugue. I have made a custom post type ('event') where a user can add a few different types of events ...
11
votes
2answers
1k views
Using pre_get_posts with WP_Query
I was reading Stephen Harris's excellent answer to this question regarding the use of WP_query(), query_posts() and pre_get_posts.
He says "pre_get_posts is a filter, for altering any query. It is ...
0
votes
2answers
462 views
using pre_get_posts for search results not found
function hotlinkers_wp_query($query) {
if ( !$query->is_admin && $query->is_search) {
$search_query = str_replace('-',' ', $query->query_vars['s']);
...
1
vote
1answer
119 views
Use post object from first query in second query
I have a post ID stored in a variable from my first query and I'd like to use that to highlight the post with the same ID in my second query, but it's not working.
First loop:
<?php if ...
0
votes
2answers
2k views
paginate_links() adds empty href to first page and previous link
This is really weird. In attempting to solve this problem i ended up with an almost perfect use of paginate_links() instead of a custom pagination function:
$myquery = new WP_Query($args);
$paged = ...
1
vote
2answers
403 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,
...
0
votes
1answer
319 views
WP_Query pagination using only numbers instead of /page/1 on URL
I don't get whats happening here.
I'm on a child-page template, generating a WP_Query for Custom Post Types on the fly, like this:
$notrel = new WP_Query(array(
'post_type' => $type,
...
0
votes
1answer
188 views
How to get from sql query page id and retrieve it url and title
Conditions:
Page have template, for example: /* Template name: News */
Explaining:
We have many pages, and one page with assigned template (/* Template name: News */).
I want on main page ...
1
vote
2answers
450 views
WP_Query not working as expected for attachments and custom meta_query
If I use get_posts() like so I get a number of results with the value 1 for the my_key meta_key:
$posts = get_posts(
array(
'post_type' => 'attachment',
'meta_key' => ...