Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come aggiungere/rimuovere le pagine predefinite in WordPress Multisite

Quando si gestisce un multisito WordPress, ogni volta che viene creato un nuovo sito WordPress aggiunge automaticamente una pagina di esempio al nuovo sito. Recentemente, uno dei nostri utenti ci ha chiesto se fosse possibile rimuovere la pagina di esempio predefinita e aggiungere le proprie pagine predefinite. In questo articolo vi mostreremo come aggiungere/rimuovere le pagine predefinite in WordPress multisito.

Perché aggiungere le proprie pagine predefinite in WordPress Multisite?

Ci possono essere molte ragioni per sostituire la pagina di esempio predefinita con una propria. Ad esempio, potreste voler aggiungere una pagina che indichi agli utenti cosa fare successivamente.

La pagina di esempio predefinita generata da WordPress è un po’ noiosa. Forse volete aggiungere qualcosa di spiritoso e intelligente?

Infine, potete utilizzare la pagina predefinita per indicare agli utenti le regole e le regole della vostra rete multisito.

Aggiunta/rimozione di pagine predefinite in WordPress

È sufficiente aggiungere questo codice al file functions.php del sito principale o a un plugin specifico per il sito.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
add_action('wpmu_new_blog', 'wpb_create_my_pages', 10, 2);
 
function wpb_create_my_pages($blog_id, $user_id){
  switch_to_blog($blog_id);
 
// create new page
  $page_id = wp_insert_post(array(
    'post_title'     => 'About',
    'post_name'      => 'about',
    'post_content'   => 'This is an about page. Feel free to edit or delete this page.',
    'post_status'    => 'publish',
    'post_author'    => $user_id, // or "1" (super-admin?)
    'post_type'      => 'page',
    'menu_order'     => 1,
    'comment_status' => 'closed',
    'ping_status'    => 'closed',
 )); 
   
// Find and delete the WP default 'Sample Page'
$defaultPage = get_page_by_title( 'Sample Page' );
wp_delete_post( $defaultPage->ID );
 
  restore_current_blog();
}

La prima parte di questo codice inserisce una nuova pagina di WordPress intitolata “Informazioni” ogni volta che viene creato un nuovo sito nella rete multisito. La seconda parte del codice trova ed elimina la pagina di esempio predefinita di WordPress.

Speriamo che questo articolo vi abbia aiutato ad aggiungere/rimuovere pagine predefinite nella rete multisito WordPress.

Se vi è piaciuto questo articolo, unitevi a noi su Google+ e Twitter. Potete anche iscrivervi al nostro canale YouTube per altri video tutorial su WordPress.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

7 commentiLeave a Reply

  1. Maxwell

    Don’t forget handle other languages too: in $defaultPage = get_page_by_title( ‘Sample Page’ ); , use:

    $defaultPage = get_page_by_title( __(‘Sample Page’) );

    This way, the Sample Page word will be translated and the page will be found in any language.

  2. ali

    thank you.
    it solved my problem. :)

    • shamim

      Hi WPBeginner i can’t remove default page Home
      i am using tweenty twelve theme.. pls help me

  3. sleon

    what do you mean about, “Simply add this code to your main site’s functions.php” in the theme functions.php?

  4. iwan

    how to removing with page more than one,for example page title(‘Sample page’,’MY product’,’Contact ‘)

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.