Skip to main content
added 645 characters in body
Source Link
Rarst
  • 99.9k
  • 10
  • 160
  • 298

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.

Create menus

This creates new menu and adds all existing pages as items to it. I am not sure it is entirely correct, I was unable to get menu items to show $menu = wp_create_nav_menu( 'Test' );Page label among other things. Anyway my brain is melting so I am taking a break. Maybe someone will be able to upgrade this to something more reliable.

$menu = wp_create_nav_menu( 'Pages' );
$menu = wp_get_nav_menu_object( 'Pages' );
$pages = get_pages();

foreach( $pages as $page ) {

$item = array(
'menu-item-db-id' => 0,
'menu-item-object-id' => $page->ID,
'menu-item-type' => 'post_type',
'menu-item-status' => 'publish'
);

wp_update_nav_menu_item( $menu->term_id, 0, $item );
}

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.

Create menus

$menu = wp_create_nav_menu( 'Test' );

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.

Create menus

This creates new menu and adds all existing pages as items to it. I am not sure it is entirely correct, I was unable to get menu items to show Page label among other things. Anyway my brain is melting so I am taking a break. Maybe someone will be able to upgrade this to something more reliable.

$menu = wp_create_nav_menu( 'Pages' );
$menu = wp_get_nav_menu_object( 'Pages' );
$pages = get_pages();

foreach( $pages as $page ) {

$item = array(
'menu-item-db-id' => 0,
'menu-item-object-id' => $page->ID,
'menu-item-type' => 'post_type',
'menu-item-status' => 'publish'
);

wp_update_nav_menu_item( $menu->term_id, 0, $item );
}
added 63 characters in body
Source Link
Rarst
  • 99.9k
  • 10
  • 160
  • 298

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.

Create menus

$menu = wp_create_nav_menu( 'Test' );

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.

Create menus

$menu = wp_create_nav_menu( 'Test' );

Source Link
Rarst
  • 99.9k
  • 10
  • 160
  • 298

Delete Hello Post (with comment)

wp_delete_post( 1, true );

Straight from wp_delete_post() docs. Second parameter nukes it completely, instead of moving to trash.