Automattic / hidden-posts

The opposite of sticky posts.
GNU General Public License v2.0
11 stars 5 forks source link

Hide from next/previous links #2

Open joshbetz opened 10 years ago

joshbetz commented 10 years ago

Hidden posts should not be shown in next/previous links

joshbetz commented 10 years ago

We should also provide a filter to turn this on or off.

joshbetz commented 10 years ago

Assuming we know vip_get_hidden_posts() is safe:

add_filter( 'get_previous_post_where', 'newsroom_mod_adjacent' ); 
add_filter( 'get_next_post_where', 'newsroom_mod_adjacent' ); 
function newsroom_mod_adjacent( $where ) {
    $posts = implode( ',', vip_get_hidden_posts() );
    return $where . " AND p.ID NOT IN ($posts)";
}