Changeset 3656
- Timestamp:
- 03/21/2006 10:46:38 PM (19 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r3655 r3656 1452 1452 else 1453 1453 parse_str($args, $r); 1454 parse_str($args, $r);1455 1454 1456 1455 $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => '', 1457 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '' );1456 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>''); 1458 1457 $r = array_merge($defaults, $r); 1459 1458 extract($r); … … 1461 1460 $inclusions = ''; 1462 1461 if ( !empty($include) ) { 1463 $offset = 0; //ignore offset, category, and exclude params if using include1462 $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value params if using include 1464 1463 $category = ''; 1465 1464 $exclude = ''; 1465 $meta_key = ''; 1466 $meta_value = ''; 1466 1467 $incposts = preg_split('/[\s,]+/',$include); 1467 1468 $numberposts = count($incposts); // only the number of posts included … … 1493 1494 $exclusions .= ')'; 1494 1495 1495 $posts = $wpdb->get_results( 1496 "SELECT DISTINCT * FROM $wpdb->posts " . 1497 ( empty( $category ) ? "" : ", $wpdb->post2cat " ) . 1498 " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions " . 1499 ( empty( $category ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. " " ) . 1500 " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts ); 1496 $query ="SELECT DISTINCT * FROM $wpdb->posts " ; 1497 $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " ) ; 1498 $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ; 1499 $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions " ; 1500 $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " ) ; 1501 $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ; 1502 $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts ; 1503 1504 $posts = $wpdb->get_results($query); 1501 1505 1502 1506 update_post_caches($posts); -
trunk/wp-includes/template-functions-post.php
r3655 r3656 307 307 308 308 $defaults = array('child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 309 'hierarchical' => 1, $exclude => '', $include=> '');309 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => ''); 310 310 $r = array_merge($defaults, $r); 311 311 extract($r); … … 313 313 $inclusions = ''; 314 314 if ( !empty($include) ) { 315 $child_of = 0; //ignore child_of and exclude params if using include315 $child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include 316 316 $exclude = ''; 317 $meta_key = ''; 318 $meta_value = ''; 317 319 $incpages = preg_split('/[\s,]+/',$include); 318 320 if ( count($incpages) ) { … … 343 345 $exclusions .= ')'; 344 346 345 $pages = $wpdb->get_results("SELECT * " . 346 "FROM $wpdb->posts " . 347 "WHERE post_type = 'page' AND post_status = 'publish' " . 348 "$exclusions $inclusions" . 349 "ORDER BY " . $sort_column . " " . $sort_order); 347 $query = "SELECT * FROM $wpdb->posts " ; 348 $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ; 349 $query .= " WHERE (post_type = 'page' AND post_status = 'publish') $exclusions $inclusions " ; 350 $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ; 351 $query .= " ORDER BY " . $sort_column . " " . $sort_order ; 352 353 $pages = $wpdb->get_results($query); 350 354 351 355 if ( empty($pages) )
Note: See TracChangeset
for help on using the changeset viewer.