Forums

Simply Hide Pages
Feature request (5 posts)

  1. concise
    Member
    Posted 1 year ago #

    It is simple!
    It hides pages from the menu!
    It does not hide pages from searches... perhaps in the next version? or in a variation?

    http://wordpress.org/extend/plugins/simply-hide-pages/

  2. julienvdg
    Member
    Posted 1 year ago #

    Thanks !

    Yes it was not designed to hide pages from the searches. I'll have to look if it's easy to do... If it is I'll do a new version ;)

  3. concise
    Member
    Posted 1 year ago #

    I 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');
  4. julienvdg
    Member
    Posted 1 year ago #

    Thanks for the code !

    In the mean time I found the following plugin (untested though) :
    simply-exclude

    I might improve simply-hide-page to also hide from search later...

  5. concise
    Member
    Posted 1 year ago #

    Simply-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 :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic