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
613 views

the_author() returns empty string

I have created a page template for the front page of a site I am building using WordPress. I am displaying the 3 latest posts on this page and all works fine except for the display of the author of ...
3
votes
1answer
540 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 ...
3
votes
2answers
402 views

Using Offset in Custom Post Type Query

I'm using the following query for a custom post type: <?php $posts = get_posts(array( 'numberposts' => -1, 'offset' => 20, ...
3
votes
1answer
163 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
342 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
818 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
4answers
2k views

Order posts by custom field and if custom field is empty return remaining posts

I have an archive page ordered by a numeric value in a custom field. This returns the ordered posts correctly, but does not display posts that don't have a custom field. $paged = ...
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
3k 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
5k 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
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
2k 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
5k 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
2answers
2k views

Custom post type archive 404's with paginate_links

im using paginate_links function to create pagination on my custom post type archives, no matter what i do im hitting 404 errors when going to view page 2 (ie clicking to go on one page in the ...
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
291 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
98 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
991 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
294 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
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
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
259 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
473 views

Perform query with meta_value date

I am trying to perform a query on a custom-type post using the value of a custom field. This field contains a string date: dd.mm.yyyy. The post type name is 'event' The custom field name is ...
2
votes
1answer
37 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
4answers
488 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
237 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
3k 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
654 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
962 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
912 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
181 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
471 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
1k 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
828 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
420 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
218 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
574 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
6k 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
736 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
90 views

WordPress query for most recent posts from multiple categories

I have 5 categories. I want to query each category and get a list of the most recent posts from them. I also only want single post from each category, with no duplicates. Is there a way to do this ...
2
votes
1answer
267 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
303 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
207 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
780 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
161 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
375 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 ...