W
W
WQP2016-09-28 23:11:21
WordPress
WQP, 2016-09-28 23:11:21

How to hide wp page?

Hello, tell me how to hide the page in the admin panel https://yadi.sk/i/s3fhmXxEvruqk so that it is not visible at all, but it exists. In other words, remove from the menu

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Yanchevsky, 2016-09-28
@WQP

Hello.
I'm guessing something like this

add_action( 'pre_get_posts' ,'exclude_this_page' );
function exclude_this_page( $query ) {
        if( !is_admin() )
                return $query;
        global $pagenow;
        if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
                $query->set( 'post__not_in', array(10) );
        return $query;
}

Together 10 substitute the ID of the desired page.
The code itself can be placed in the functions.php of the theme, but it is better to put it in the form of a plugin or use plugins for inserting snippets, such as Add Shortcodes Actions And Filters .

S
Sergey, 2016-09-29
@void01

It seems that the WP-Edit plugin that extends the editor has the ability to specify post IDs to hide.
a very necessary by the way plugin from the must-have list on any project

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question