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 a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

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

Let's Talk