A generic term referring to the process of retrieving information from a database.

learn more… | top users | synonyms

198
votes
6answers
62k 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?
10
votes
1answer
6k views

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum ...
13
votes
3answers
12k views

Pagination not working with custom loop

I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function: <?php $sixtydays = date('Y/m/d', ...
7
votes
4answers
2k views

the_date() not working

I am using wordpress 3.2 and I did a query post like this: <?php query_posts("posts_per_page=1post=type&page=post_parent=10");?> Then I try to echo out the date of this post I queried ...
1
vote
1answer
978 views

Show only oldest post by author

I am working with a heavily customized install of WP. I've set up a specific post type, taxonomy, and roles that gets to use just that post type. Ideally, I'd like to restrict members of that role ...
0
votes
1answer
194 views

How do I sort multiples pages?

I want to use a dropdown to sort a list of posts in WordPress. The results will display on multiple pages. So how do I pass the query on to the second, third, fourth, etc. pages? Here's an example of ...
0
votes
2answers
295 views

Duplicate posts

I'm currently working on a Magazine style website and on the main page I have three different sections where I display the latest news. Slider, latest news and more news. The problem is I can't ...
3
votes
2answers
774 views

Sort custom post type list table by display name of a user id stored as post meta value

I have a custom post type named domicile. Each post (domicile) has an owner (not the author). Owners are users with a custom role. I store the user id as a post meta value (dmb_owner) for the domicile ...
0
votes
2answers
2k views

How to order posts by modified date without using 'query_posts'?

I have an example basic wordpress theme template here for you. First, please take a quick look at it to get an idea. <?php get_header(); ?> <div id="primary"> <div ...
3
votes
3answers
8k views

Using nextGen Gallery.. how can I call a list of all Gallery Names?

I'm trying to make a nav to access all the different galleries on a single page. Instead of hard-coding all their names out. I was curious if it was possible to make this dynamic and just call all ...
8
votes
6answers
11k views

Wp get all the sub pages of the parent using wp query

Here is my code $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page','post_parent'=>$parid,'orderby'=>'title','order'=>'ASC' )); It displays ...
6
votes
1answer
6k views

Get all image from single page using this query

I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the ...
5
votes
6answers
4k views

How can I make wp-pagenavi work on a custom query built upon a form submission?

I've also posted this on the wordpress support forums, for scribu's wp-pagenavi plugin: http://wordpress.org/support/topic/plugin-wp-pagenavi-custom-query-form-submit-part-2?replies=1 My situation: ...
2
votes
1answer
3k views

WordPress Paginate $wpdb->get_results

Due to a complex multisite config, I have a query which combines the posts from two blogs and I would like to paginate the results. I am grateful for any help. I have posted my query. ...
2
votes
4answers
3k views

get attachments for all posts of particular post type

I'm making a widget that shows a set of images from recent custom posts. I want to run the following query: SELECT p.* FROM wp_posts p WHERE post_type='attachment' AND post_mime_type LIKE 'image%' ...
0
votes
1answer
468 views

Custom Query: query by post custom meta data

So I have a custom post called event, but I need to query only those posts which have a custom metabox(is a checkbox) called `Show On The Homepage: and only if that checkbox is checked. <?php ...
0
votes
1answer
687 views

Filter all queries with a specific taxonomy

Is there any way to filter all post queries and add a specific taxonomy? Case in point, I have a taxonomy object of "Region" with terms like "Global", "Americas", "Europe", etc. (Users designate ...
1
vote
2answers
860 views

Specific Loop For 2 <div> Within Each <li>

I need to create a loop that can logically be described as the following for a carousel: Requirements: 3 Loops 2 Posts Per Loop No Duplicates Order by Post Date Visual: < Start Loop #1 > ...
0
votes
1answer
196 views

Adjust the order for returned posts

I have written a neat responsive slider for my Wordpress featured articles (feel free to use it): <?php $responsive = 'on' != get_option('henrik_responsive_layout') ? false : true; ...
0
votes
3answers
2k views

Custom $wpdb Query for Custom Post Type by Category

I am using the following code to output a list of items in my 'documents' Custom Post type by Year and Month. <ul> <?php $post_type = 'documents'; global $wpdb; /**/ $years = ...
0
votes
2answers
2k views

All in One Calendar Plugin Custom Post Type Query [closed]

Hi I'm trying to write a query which will pull the events out from the All in One Calendar Plugin. This is what I have so far: <?php query_posts('post_type=ai1ec_event');?> <?php while ( ...
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' ...
-1
votes
1answer
54 views

Highlighting Sub topic in a post?

Have seen this sub topics highlighter in many blogs. It gives a special attraction to a sub topics used in the post. Is this a plugin or part of code? How can I add this? http://imgur.com/UbGpz7j
7
votes
3answers
604 views

Order posts (across the whole site) by metadata date

My custom 'Home' page is set to sort my custom posts via the custom date field with this (updated to be custom named) code in functions.php: // sort order for home page add_action('wp', ...
14
votes
4answers
2k views

Show a different number of posts per page depending on context (e.g., homepage, search, archive)

In the Reading Settings, there is place to set the number of posts shown that affects the number of posts shown in all contexts. I'd like to show instead a certain number of posts on the homepage, and ...
4
votes
3answers
2k views

Optimize Multiple Taxonomy Term MySQL Query?

(Moderator's note: Title was originally: "query/database optimisation") I'm written a function for a custom "filter" search panel that allows users to select terms from up to four custom taxonomies. ...
0
votes
2answers
3k views

wp_query orderby title and meta key value (WP3.1)

I have a taxonomy wp_query and i would like to order the list by title and by meta value (numeric value) Have a meta value Interesting = 1 or 0 in the posts Not so interesting posts would be at the ...
1
vote
3answers
332 views

Delete post revisions on post publish

Is it possible to delete post/page revisions from the database when a post/page is published? 11/05/12 Answer: See the plugin below by bueltge I want to do this on a site with 5,000 posts and ...
1
vote
3answers
730 views

Possible to filter the posts or categories that XML-RPC users see in their mobile application?

Is it possible to filter the posts or categories that XML-RPC users see in their mobile application? I have a plugin that hooks into pre_get_posts and list_terms_exclusions to do what I need it to ...
0
votes
1answer
1k views

Query multiple taxonomy in Custom Post Type

Currently I use: query_posts("post_type=listing"); to pull all entries of my custom post type. But I have a taxonomy called status with the values of Available, Pending, Sold. I only want to show ...
4
votes
1answer
2k views

restrict_manage_posts not working in 3.3.1

I have noticed my custom taxonomy filters no longer work in the 3.3.1 admin as per these methods: Adding a Taxonomy Filter to Admin List for a Custom Post Type? I also discovered that to filter a ...
4
votes
1answer
580 views

Why does `get_permalink()` produces an add. DB request without $post->filter?

I'm currently working on a custom loop/query where I need to add the permalink of a post to the array of posts I'm retrieving from the DB. Sadly get_permalink() produces one additional DB request ...
3
votes
1answer
3k views

Meta Query with AND & OR?

I'm trying to do some filtering for some posts in WP_Query, but I can't seem to get the right condition. Basically what I wanna do, is get posts that have the custom field event_data (sorted by this ...
2
votes
1answer
332 views

Adding posts of custom type into the main feed

I'm having some trouble with a subject that seems to be pretty basic, so I'm starting to feel (a little, only a little) dumb :-) Here's the thing: I want my main feed to include the posts and other ...
1
vote
1answer
716 views

Is there any need to use both wp_reset_postdata and wp_reset_query together?

Is there any need to use both wp_reset_postdata() and wp_reset_query() together? Is it a case that I would pick one of the two functions; is there any point in doing this after a query : ...
1
vote
2answers
1k views

How do I search inside specific taxonomies in Wordpress

I am trying to search for posts in specific taxonomies but any time I search, I get results from all the other pages instead of Wordpress searching within the selected category in the taxonomy. I ...
1
vote
3answers
474 views

Search and replace text across all posts

I had used the ZD Video Plugin for WP a long time, and now, since my move to WP 3.0.2, it doesn't work anymore. To embed a YouTube video using the plugin, I would just write ...
0
votes
1answer
129 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
0
votes
3answers
715 views

how to get a different html for odd/even posts?

query posts if posts exist then begin the loop if post is even: <h1>title</h1><p>content</p> if post is odd: <div>its ...
0
votes
1answer
782 views

pagination in author.php template returns 404 error

Hi to the community!!! I need some help with pagination in author.php template. I have pagination working in all my loops except in authors.php that i get a 404 error. In my settings/reading i have ...
0
votes
1answer
544 views

Display Post by taxonomy and taxonomy child

This is a follow up to Display Post by taxonomy and taxonomy child if exist I need to display a list of Accomodation, first by Type of Accomodation, then by Regions. I have a post-type, called ...
0
votes
1answer
1k views

Custom Permalinks Break Search Pagination

So I'm having a weird issue that I've never seen. I have a search.php set up like this: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string . '&paged=' . ...
4
votes
2answers
393 views

How to display Section for certain time

i am building a News site. I want to display 1 featured post from "prime" category for only few hours. after it should be expired or disappeared from the section. please have a look here u can see ...
2
votes
1answer
199 views

Save default value for empty or missing post meta

I am using WordPress and I am using a custom field that has the name ecpt_carprice for each post I am publishing, the field is saved in wp_postmeta the same as the attached image: Some of my cars ...
2
votes
1answer
252 views

How navigation works in custom loop within shortcode?

I am using a shortcode to display a custom query. The shortcode is use in page. Everything is fine, only the navigation that I can't get it working correctly. Here is the function that I use to ...
2
votes
1answer
235 views

Multipart/formatted MySQL query problem

I'm creating a plugin and I want to automate the creation of a MySQL Trigger on a table. The problem seems to be that $wpdb->query doesn't appear to accept either multipart statements and/or formatted ...
2
votes
1answer
981 views

query multiple taxonomy and show post count

I have custom post type 'Product', and 2 custom taxonomies 'category' and 'product status'. What i am trying to do is list categories in page template and show how many total products in category ...
1
vote
1answer
59 views

Only display a certain number of posts, dependent on how many posts there are available in a query

I am trying to write some code for a slider of posts, at the moment my code involves two WP_Querys, one inside the other, but I can't help feeling there may be a more efficient way of doing what I'm ...
1
vote
2answers
100 views

is_archive() doesn't work on public query var archive pages?

Public query vars are those available and usable via a direct URL query. E.g. example.net/?category_name=tech&tag=gadgets But doesn't example.net/?category_name=tech&tag=gadgets show ...
1
vote
1answer
90 views

Transient pagination not working properly

So I wrote the following to create a transient: $wp_object_i_created = new WP_Query('cat=1'); set_transient('category_one_posts', $wp_object_i_created, 60*60*1); Ok so then I decided "Ya know lets ...