Tagged Questions
3
votes
2answers
117 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
98 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
65 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
708 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
189 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
98 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
482 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
444 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
89 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
271 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
135 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 ..
...
0
votes
2answers
3k 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
413 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
110 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 ...
145
votes
3answers
37k 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?