concise
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Simply Hide Pages] [Plugin: Simply Hide Pages] Feature requestSimply-Exclude looks good but for pages it appears to only exclude them from searches. And with 2084 lines of code, it is slightly longer than your plugin 🙂
Forum: Plugins
In reply to: [Simply Hide Pages] [Plugin: Simply Hide Pages] Feature requestI managed it by adding the following to functions.php, but would go better in a plugin (but really WP should have Visibility: public, password, private & hidden.
/* * from brickbrigade's code at http://wordpress.org/support/topic/get_post-query-where-posts-dont-have-a-specific-meta_key-1 */ add_filter('query_vars', 'metakey_queryvars' ); function metakey_queryvars( $qvars ) { $qvars[] = 'not_meta_key'; return $qvars; } add_filter('posts_where', 'metakey_where' ); function metakey_where( $where ) { global $wp_query; global $wpdb; if( isset( $wp_query->query_vars['not_meta_key'] )) { $where .= $wpdb->prepare(" AND $wpdb->posts.ID NOT IN ( SELECT post_id FROM $wpdb->postmeta WHERE ($wpdb->postmeta.post_id = $wpdb->posts.ID) AND meta_key = %s) ", $wp_query->query_vars['not_meta_key']); } return $where; } /* * variation of jamesstiff's code at http://wordpress.org/support/topic/excluding-pages-from-search-results */ function mySearchFilter($query) { if ($query->is_search) { $query->set('not_meta_key', 'hide'); } return $query; } add_filter('pre_get_posts','mySearchFilter');
Viewing 2 replies - 1 through 2 (of 2 total)