Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

learn more… | top users | synonyms

3
votes
1answer
547 views

Display Posts by modifying the where clause only for my query

I am trying to display posts that are 7 days old. For that i need to modify the 'where' clause as in code //Hack found on the bottom of http://codex.wordpress.org/Template_Tags/query_posts ...
3
votes
1answer
158 views

How should I intercept the main query and inject custom join / order by / group by criteria

I have a CPT that is a member of two separate taxonomies. On the taxonomy archive page for one of the taxonomies, I need to further group and sort on the second taxonomy like so: ...
3
votes
1answer
1k views

Display only the latest post from multiple categories

I have a jQuery slider at the top of my index.php, which works fine. The only problem is that I would like to use query_posts to only display the latest post from five different categories, and always ...
3
votes
1answer
309 views

Query posts: how to exclude results if post is in multiple categories

Say I have 3 categories: A, B, C, and another category D that posts in A,B,C can also be assigned to. D is to denote the featured post for the category, and theoretically only one post for each (A, ...
2
votes
2answers
763 views

Using categories & “stickyness” together

I've got a custom query on my homepage showing all posts in a certain category. I need this query to respect sticky posts, but it seems from my research that category queries ignore stickyness. My ...
2
votes
1answer
1k views

WP_Query vs get_posts

I have read a number of questions on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of ...
2
votes
4answers
1k 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: ...
2
votes
2answers
2k views

Advanced Tax Query

Below is my tax query, at the moment this returns all posts which have at least one of the specified terms. Is there a way I can have it return only posts which have ALL of the specified terms? ...
2
votes
1answer
3k views

pre get posts changing the query

i need to change the posts in taxonomy.php page. I have a meta_key which i want to compare to meta value. But currently my code is not returning anything. I am sure i am missing something. Please let ...
2
votes
3answers
1k views

query recent posts from several categories

i'd like to list my 10 most recent posts but from certain categories only - anyone can tell me how to do this? thanks
2
votes
3answers
4k views

Return all custom meta data for one custom post type

I've set up a custom post type which has three custom meta fields: name, latitude, longitude. Each post already shows the name on an integrated map based on it's latitude and longitude. I now would ...
2
votes
1answer
4k views

How can i get count from query post

How can i get the row counts in query post like mysql count(*). $obj_name = new WP_Query($args); while ($obj_name->have_posts()) : $obj_name->the_post(); // here i want to predict looping ...
2
votes
3answers
8k views

How to use query_posts() with a date filter on a custom field?

I have defined a custom post type that uses a meta field to store dates. In my functions.php I have the following code which saves the start date. The format of the date that is sent in the startdate ...
2
votes
1answer
2k views

Loading Custom Post Type Events into jQuery-based FullCalendar?

Here is a question I have spent over 3 hours attempting to solve but each approach I take ends up not working out for me. All I am attempting to do is utilize this opensource ajax calendar script: ...
2
votes
2answers
212 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 ...
2
votes
2answers
96 views

Different amount of posts on homepage than paged pages

I've done some searches here and on Google but everything I'm finding isn't working correctly. I was hoping to post my code here and get help with where I'm going wrong. On the index page of my ...
2
votes
3answers
859 views

Post count per (day/month/year) since blog began

I'm looking to echo the number of posts per month since the blog began, and for months where there was no posts echo '0'. This is the output I want: January 1, February 3, March 8, April 3, ... ...
2
votes
1answer
264 views

Determine if more posts are available than was asked for in `query_posts()`?

I'm getting products (from a specific category) using a custom query_posts() function. I limited the showposts parameter to 25, so how do I know to activate pagination if there are still products ...
2
votes
1answer
2k views

How do i paginate query_posts with numeric pagination?

I have post type called blog and i'm showing posts for the type using query_posts, eg. query_posts('post_type=blog'); I would like to add pagination for this post type in the following format. ...
2
votes
2answers
2k views

Alter query on edit.php

What's the best way to alter the query being run on the Posts Edit screen (edit.php)? The current method I'm using is by passing an argument to the global $wp_query like so: $wp_query->query( ...
2
votes
1answer
202 views

Can't show comments count per post outside loop

How can I show the amount of a comment per post outside the loop? I tried this in a function already: ' . get_comments_number . ' , but that outputted the text "array" on the screen... What do I have ...
2
votes
1answer
35 views

Last posts from custom taxonomy

How can I post last posts from custom_taxonomy? I tried this like, but it doesn't works. $terms=get_terms('tax_name'); $request=array(); if(count($terms)>0) { foreach($terms as $t) { ...
2
votes
1answer
2k views

Nested meta_query with multiple relation keys

I am curious whether Wordpress is able to run nested meta_query, with each having different relation keys? As of Wordpress 3.0, tax_query is able to perform this function; I'm wondering whether this ...
2
votes
4answers
442 views

Query Posts in a Predefined Order

I am using the query_posts function to list a 10 specific posts which lookup by post id. I have an array which looks like this.. Array ( [0] => 17983 [1] => 17932 [2] => 18030 ...
2
votes
2answers
2k views

List posts by category exclude current post

I'm trying to get a list of posts from one category, echo the title and the permalink of all posts on that category but exclude the permalink and the post name IF the current post is on that list. It ...
2
votes
2answers
234 views

Wordpress Plugin Setting's POST

I've developed a few plugin for Wordpress. Currently I've not been able to replicate the way wp save settings. I've a setting page which I learned from a tutorial. It POST to option.php, and wp take ...
2
votes
3answers
1k views

How to get the parent's taxonomy?

I have 2 customs post type : "Artist" and "Concert", the "Concert" custom post type is the child of the "Artist" custom post type, the "Artist" custom post type has a "genre" taxonomy. What I'm ...
2
votes
1answer
2k views

Pagination on archive.php page

I have an archive.php page with the following code: <?php // Start your custom WP_query $my_query = new WP_query(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = ...
2
votes
1answer
632 views

Use union/intersection query_posts variables in uri request parameter form?

Usually when I create some form of query, I use an array for my arguments like this: $postslistArgs = array( 'child_of' => 320, 'parent' => 320 ); $postslist = ...
2
votes
1answer
835 views

exclude ids through post__not_in

I am trying to make a function and exclude in the post query that way im able to define the id's in my function but it is only excluding 1 post instead of the 4 it is returning. any suggestions on ...
2
votes
1answer
834 views

Custom search filter causes menu and query_posts problems

I'm using a custom search filter (using my custom query var type), like so: function fteh_pre_get_posts( $query ){ if( isset( $query->query_vars['type'] ) ) $types = explode( ',', ...
2
votes
2answers
161 views

How to get 4 Posts after the 5 most recent ones

Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth - most recent ...
2
votes
5answers
433 views

Different number of posts on the front page

I want 5 posts on my front page but 10 posts on subsequent pages (page 2, 3, ..). In my Settings > Reading > Blog pages show at most > I have 10. But I want to show only 5 posts on the front page, so ...
2
votes
1answer
991 views

Featured Posts for Category Pages

I was wondering if anyone knew how to have a different "featured post" based on it's category per category page? For example, if you are on the medical category page, you would see a medical post ...
2
votes
2answers
814 views

Query 1 taxonomy term, exclude another

Here's the code I'm using to try and query a single taxonomy for one term, but exclude returned posts for that term that also belong to another. In English, this is what I want: query 'resource-type' ...
2
votes
1answer
390 views

Get all posts WHERE custom_field is LIKE value

I'm trying to do a MySQL-style search with Wordpress' built-in functions for fetching posts. There's likely a simple way to do this and I'm probably just a little bit off from the solution. We have ...
2
votes
2answers
210 views

Post the content of a specific “Custom Post Type” post within a post using a shortcode

The posts on our music blog usually include multiple tracks of music. I want to have each individual track be its own entity--a custom post type called "track"--which I want to be able to insert ...
2
votes
1answer
539 views

How to hook get_terms() to only show count of posts that have custom meta

Here is what I have: A custom post type that has a custom meta value added to a post that stores the posts expiry date. When the post passes this expiry date it no longer shows on the site. This ...
2
votes
2answers
5k views

Best way to load page content in Fancybox popup?

I would like to have some links which load the page content of the page they reference to inside a Fancybox popup(pages like "shipping" or "returns", mainly text content). I would create the pages an ...
2
votes
2answers
723 views

Conditionally Query Custom Post Types by Post Meta for Blog Home Page?

(Moderator's note: The question's original title was: "Custom query: Show custom post types plus custom post type with post meta on blog homepage") I'm in need of help with a custom query. I have ...
2
votes
1answer
233 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 ...
2
votes
1answer
272 views

Using database meta_values to calculate new post order using pre_get_posts or a 'request' hook

UPDATE: I have worked out my implementation of the selected answer at the bottom of this post. I'm implementing a sorting algorithm based on Reddit's hotness algorithm, in addition to a time-decay ...
2
votes
3answers
164 views

Exclude category from loop not working

I have this code in my index.php file. I have a different template for a static home page, this is the blog page. I'm trying to exclude all posts with the category "new" which is tag_id "13" <?php ...
2
votes
1answer
660 views

Order by meta_key with two meta_queries

This should be simple, but I just can't pinned down a good example of the correct syntax to do this. I want to order by the specified meta_key with two meta_queries. The problem is query_posts ...
2
votes
1answer
160 views

reference the current category being used in the category.php page

I have this code in my category.php file <?php query_posts( array('post_type'=>'featured' )); $featured = new WP_Query( array('posts_per_page'=>1, 'tax_query'=> ...
2
votes
2answers
369 views

How to order results by date and meta key?

I'm using wp-postratings to rate posts which stores the rating as a custom meta value ratings_score. It gives you the option to use r_sortby to order the loop by highest rated but I want to give it a ...
2
votes
3answers
765 views

Pagination on custom query

I'm using the following code with query_posts to put together a custom search: $args = array( 'post_type' => 'species', 'meta_query' => $meta_query, 'tax_query' => $tax_query ); ...
2
votes
1answer
119 views

Can ordering post list by meta_value cause performance issue?

For some code refinement and to add new features to my plugin, I want to display posts ordered by specific meta column value like this; query_posts($query_string . ...
2
votes
1answer
364 views

Order by value in serialized custom field

Quite a pesky problem here. I've taken over a site that contains multiple information, serialised, within a custom field. For example: if ($new_query->have_posts()) : while ...
2
votes
1answer
527 views

query_posts sort in multiple directions

I'm trying to improve my post sorting by using multiple criteria, but I want specific orders for different values. For example, I have a meta_key called 'featured' that I want to move any post up to ...