Display Posts Lockdown

<?php
/**
* Display Posts Lockdown
*
* Disables the ability to query by post status and certain post types
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/display-posts-lockdown
*
* @param array $args, WP_Query arguments
* @param array $atts, Shortcode attributes
* @return array $args
*/
function be_display_posts_lockdown( $args, $atts ) {
$args['post_status'] = 'publish';
$excluded_post_types = array( 'revision' );
if( isset( $args['post_type'] ) && in_array( $args['post_type'], $excluded_post_types ) )
$args['post_type'] = 'post';
return $args;
}
add_filter( 'display_posts_shortcode_args', 'be_display_posts_lockdown', 10, 2 );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk