get_boundary_post [ WordPress Function ]
get_boundary_post ( $in_same_cat = false, $excluded_categories = '', $start = true )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: get_boundary_post_rel_link, get_blog_post, get_next_post, get_previous_post, get_body_class
Retrieve boundary post.
Boundary being either the first or last post by publish date within the constraints specified by $in_same_cat or $excluded_categories.
Source
<?php
function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $start = true ) {
global $post;
if ( empty($post) || ! is_single() || is_attachment() )
return null;
$cat_array = array();
if( ! is_array( $excluded_categories ) )
$excluded_categories = explode( ',', $excluded_categories );
if ( $in_same_cat || ! empty( $excluded_categories ) ) {
if ( $in_same_cat )
$cat_array = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
if ( ! empty( $excluded_categories ) ) {
$excluded_categories = array_map( 'intval', $excluded_categories );
$excluded_categories = array_diff( $excluded_categories, $cat_array );
$inverse_cats = array();
foreach ( $excluded_categories as $excluded_category )
$inverse_cats[] = $excluded_category * -1;
$excluded_categories = $inverse_cats;
}
}
$categories = implode( ',', array_merge( $cat_array, $excluded_categories ) );
$order = $start ? 'ASC' : 'DESC';
return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) );
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/get boundary post « WordPress Codex
Description. Get the first or last post by publish date. Usage. <?php get_boundary_post( $in_same_cat, $excluded_categories, $start ); ?> Parameters ...
codex.wordpress.org - #14035 (get_boundary_post() sorts by ID rather than creation date ...
When get_boundary_post calls get_posts, posts are sorted by their ID rather than creation date. In other words, if old posts were imported or post IDs are skewed ...
core.trac.wordpress.org - get_boundary_post | A HitchHackers guide through WordPress
Feb 12, 2011 ... function get_boundary_post($in_same_cat = false, $excluded_categories = '', $ start = true) {}. Retrieve boundary post. Boundary being either ...
hitchhackerguide.com - get_boundary_post() WordPress function reference, arguments and ...
get_boundary_post(). Retrieve boundary post. Boundary being either the first or last post by publish date within the constraints specified by $in_same_cat or ...
queryposts.com