mediopirzel
Member
Posted 1 year ago #
Hi all,
Is there a way to exclude only one page? It is very easy to add a page or post by id or slug but I need to exclude one page.
I'm using template 0 in all pages, but I don't need the form in one specific page.
I tried with a "-" sign without success.
Any idea ?
http://wordpress.org/extend/plugins/custom-field-template/
Hi,
Not possible with the plugin, however you should be able to remove it using a WordPress hook
add_action( 'add_meta_boxes', 'my_remove_post_meta_boxes' );
function my_remove_post_meta_boxes() {
$post_id = $_GET['id'];
if( $your_excluded_id == $post_id ):
remove_meta_box( 'cftdiv', 'page', 'normal' );
remove_meta_box( 'cftdiv', 'post', 'normal' );
endif;
}
Put that in your functions file.
Read more about this technique here:
http://justintadlock.com/archives/2011/04/13/uncluttering-the-post-editing-screen-in-wordpress
mediopirzel
Member
Posted 11 months ago #
Hi,
Thank You for your answer. I'll give this a try.
mediopirzel
Member
Posted 11 months ago #
There is a little mistake in the code.
Instead of using $_GET['id'], you have to write $_GET['post']
add_action( 'add_meta_boxes', 'my_remove_post_meta_boxes' );
function my_remove_post_meta_boxes() {
$post_id = $_GET['post'];
if( $your_excluded_id == $post_id ):
remove_meta_box( 'cftdiv', 'page', 'normal' );
remove_meta_box( 'cftdiv', 'post', 'normal' );
endif;
}
And It works!!!
Thank you