0
votes
3answers
52 views

How to show more than 5 posts?

I am running code that shows child categories, and all posts in the child categories. But if there are more than 5 posts in a category, only the 5 newest are shown. How can I show all, or at least ...
0
votes
1answer
73 views

Retrieve posts in custom post type and specific taxonomies

I'm struggling with what seems like should be so simple looking at the codex. I have a custom post type, let's call it 'portfolio'. A custom taxonomy for that, let's call it 'clients'. I can use ...
0
votes
2answers
70 views

How to get posts and comments amount per hour, per year and per month?

I have this snippet: function count_user_comments_today( $uid ){ global $wpdb; $today = date('Y-m-d'); $tomorrow = date('Y-m-d', time() + 86400); $count = $wpdb->get_var( ...
3
votes
2answers
207 views

Very slow query

This query works, but it takes upwards of 20 seconds to run on a Quad Core dedicated server... How can I optimize this? $slides=get_posts( array('post_type' => 'any', 'numberposts' => 5, ...
0
votes
1answer
179 views

Why posts array is empty?

I try to get posts that either do not have a custom field set or if set have a value not like a given parameter. Here is my code: $args_included = array( 'numberposts' => 1, ...
1
vote
1answer
102 views

How to optimize my query filtering out unwanted data?

I use get_posts ($arg); to query the post table. Usually I need only three fields: post_title, ID and post_excerpt. But the data returned are many more, including post_content that is usually huge. I ...
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 ...
0
votes
1answer
321 views

Remove posts from query for events whose start date has passed

The query below works as expected, showing cpt event ordered by meta_value, what I haven't figured out yet is how to remove posts for past events or events which have started. The start date for ...
0
votes
1answer
107 views

Can I include get_posts in this array?

I am using the custom meta box script from deluxeblogtips.com and I wondered if I could include get_posts within this array so that it displays all posts within a set post type ("Locations" for ...
0
votes
2answers
2k views

Get posts by meta data OR title

I have a working query that calls all my posts that have a certain meta value for one of two meta keys: $term = $_GET['term']; $args = array( 'post_type' => 'some_cpt_name', 'meta_query' ...
0
votes
1answer
871 views

Get the ID of the latest post

Been all over looking for the best way to do this. I want to get the ID of the latest post of a certain post_type. How can I do this in the cheapest way possible (by cheapest I mean using the least ...
5
votes
1answer
512 views

How to organize and cache additional data associated with terms?

I'm updating a plugin of mine and am have a hard time figuring out the "best way" to build in a specific bit of functionality. The plugin allows users to associate images from their media library to ...
0
votes
1answer
92 views

Number of posts in the archive

How do I show 10 posts on the first page of the archive, and 20 on others (>1)? My custom post type name is "apartments". Cheers!
0
votes
1answer
309 views

Prioritising and Ordering Posts By Category Name Using A Custom Loop

I have a custom loop pulling out videos all assigned to various categories. However there is a category called "new-video" and I need to pull out all videos using my custom loop, but I would like the ...
0
votes
1answer
138 views

Page displays content from different query?

How can I reset all variables in order to get the actual page content? I keep getting the last post's content I've called from a news-box I've implemented - but need the actual page's content .. ...
1
vote
2answers
4k views

Does meta_query work within get_posts array?

I can't seem to get this to work — I'm trying to show posts that have the meta 'featured_image' value set to anything. From what I can tell, it's set up correctly, but I'm in a little over my head. ...
0
votes
1answer
420 views

Custom query for custom post_type

I need to display a list of current tasks. Each task has a custom post_type and a start date and end date. Can someone tell me how to modify my query so it will pick up any tasks that have a start ...
0
votes
1answer
145 views

pre saved posts query from db options table

I found a question about magazine style front pages that queries always only 1 post (or custom_post_types, etc.) from a whole load of different categories, tags or custom taxonomies. I thought about ...
183
votes
6answers
57k views

When should you use WP_Query vs query_posts() vs get_posts()?

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query. What's the deal?