Skip to content

Instantly share code, notes, and snippets.

@DanielFloeter
Last active October 28, 2020 07:35
Show Gist options
  • Save DanielFloeter/46f23a8ffda7cbb89ea186260b0fb5ae to your computer and use it in GitHub Desktop.
Save DanielFloeter/46f23a8ffda7cbb89ea186260b0fb5ae to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Show Hidden Posts Add-on
Plugin URI: http://tiptoppress.com/downloads/term-and-category-based-posts-widget/
Description: Extension to show also hidden Posts ("Wordpress Hide Posts") for the premium widget Term and Category Based Posts Widget.
Author: TipTopPress
Version: 1.0.1
Author URI: http://tiptoppress.com
Installation:
- Download the file and rename it to Show-hidden-Posts-Add-on.php
- Upload it to the plugins folder [your-wordpress-installation]/wp-content/plugins/Order-by-Add-on.php
- Go to WordPress > Admin > PlugIns and activate the Extension
- Now, hidden Posts should be shown just with the widget and not anywhere else
*/
namespace termCategoryPostsPro\ShowHiddenPostsAddOn;
// Don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Applied to the list of wp_query args.
*
* @return array of sort orders
*
* @since 0.1
*/
function query_args ( $query_args, $that, $instance ) {
// Custom, Jeff: WordPress Hide Posts
// override widget filter ('Wordpress Hide Posts') pre_get_posts with prio 20
add_action( 'pre_get_posts', __NAMESPACE__.'\hidden_posts', 20 );
return $query_args;
}
add_filter( 'cpwp_query_args', __NAMESPACE__.'\query_args', 10, 3 );
// Custom, Jeff: WordPress Hide Posts
function hidden_posts ( $query_args ) {
$query_args->set( 'meta_key', '' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment