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.
2
votes
3answers
447 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
155 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
4answers
3k views
Query posts by custom taxonomy ID
I have a custom post type called portfolio and a custom taxonomy called build-type (acting as categories)
I am trying to query portfolio posts by build-type ID e.g. all Portfolio posts in "Hotels" ...
2
votes
2answers
1k 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
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
1answer
28 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
164 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
1k 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
170 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
557 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
27 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
177 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
2answers
118 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
1answer
837 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
718 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
292 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
168 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
394 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
1answer
959 views
Custom Post Type “Event”: chronological list of recurring events
i'm looking for a good and easy way to have a custom post type "event" that can have multiple dates. (I have tested about 20 plugins). I think i have no problem building a metabox allowing the user to ...
2
votes
2answers
4k 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
680 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
107 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
1answer
139 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
367 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
1answer
126 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
293 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
442 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
101 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
284 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
301 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 ...
2
votes
1answer
280 views
Search stores (custom postcode field) within 5, 10, 15 miles of user inputted postcode.. Code modification
I have been searching for a location search solution for wordpress.. The best semi-solution I have found is http://mondaybynoon.com/2010/02/22/store-locator-wordpress-pods
The problem being is that I ...
2
votes
4answers
262 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
339 views
“NOT ONLY IN” taxonomy query operator?
I have multiple users adding content to restricted categories (using RoleScoper) in my WordPress setup that don't show up on the homepage (custom template with query_posts()).
I'm looking for a way ...
2
votes
1answer
612 views
How to dynamically build a multiple taxonomy query loop within a post type's single loop?
This question is a little different then the others floating around here. The most similar one is "How to get the parent's taxonomy ?".
I have a music cms setup that utilizes two post types: album ...
2
votes
1answer
151 views
advice on creating a 'related posts' query like the one used on stackexchange
One of the things that I most enjoy about the stackexchange website is the 'related questions' that show up on the sidebar when I am viewing a question (or show up as I am typing my question). It is ...
2
votes
1answer
119 views
order by meta_value serialized array
Hi I'm trying to pull posts using the wp query. Just one problem--I am trying to sort the posts alphabetically by a certain meta_value. Thing is that this meta_value is a serialized array. Is there an ...
2
votes
1answer
206 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 ...
2
votes
1answer
56 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
324 views
Page navigation doesn't show when query category
Problem:
when I do www.example.com?cat=4 or choose category through custom menu or from category widget it shows only first page without navigation at the bottom, where it supposed to be. It's the ...
2
votes
1answer
217 views
get_query_var('paged') always returns empty
Putting this up after having hit a brick wall for possible solutions.
Have a site with quite a few custom post types and associated custom taxonomies. To help make things easy, I'm using a unified ...
2
votes
2answers
83 views
Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post_photographer and post_videographer).
What I am ...
2
votes
2answers
77 views
Multiple instances of Featured Image Query
I have some custom code built into the header of my theme that gets the featured image from a post, displays the image and links to the posts permalink when clicked on by a user.
The problem I am ...
2
votes
1answer
35 views
How do I query for a post by custom field?
I have a custom field called "song-id" and I'd like to lookup a post by a song-id value. Can someone give me the code snippet for it?
(bonus: also looking for a code to use the permalink in the post ...
2
votes
2answers
311 views
mysql custom wp query
this code is designed to select posts with selected meta value in wordpress query
<?php $values = $wpdb->get_results("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = ...
2
votes
1answer
168 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
0answers
784 views
query_posts with a custom post type, a meta_query and sorting by post date?
I've searched the archives and found questions similar to what I need, but haven't found exactly what I want.
I've got a bunch of products that are sorted by a meta_key of country, and I'd like to be ...
1
vote
3answers
365 views
Insert all post IDs in new database table
I have a plugin which creates a new database table. Upon activating the plugin is there a way to insert all my posts ids into that table?
Right now I'm using an action hook to immediately insert the ...
1
vote
2answers
592 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 ...