You are deleting all pages with that code because you are triggering the function wp_delete_post().
You should build the url to delete the page(or post) like this:
$delLink = wp_nonce_url( get_bloginfo('wpurl') . "/wp-admin/post.php?action=delete&post=" . $page->ID, 'delete-post_' . $page->ID);
So your code should be:
$pages = get_pages();
foreach ( $pages as $page ) {
$delLink = wp_nonce_url( get_bloginfo('wpurl') . "/wp-admin/post.php?action=delete&post=" . $page->ID, 'delete-post_' . $page->ID);
$option = '<li>';
$option .= '<a href="' . $delLink . '">';
$option .= $page->post_title;
$option .= '</a>';
$option .= '</li>';
echo $option;
}
Cheers
Related Posts:
- Determine if page is the Posts Page
- Keyboard shortcut for updating a page or post?
- Apply the_title() filter in post & page title, but not in menu title
- Difference between an archive and a page listing posts
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- Strategy for handling hierarchical pages with empty parent content
- How to add a new tab to page editor
- How to display the page title/content in the Posts page?
- Callback for wp.autosave.server.triggerSave();
- disable password protected page for logged users
- How to change post to page
- RSS for Pages Instead of Posts?
- Why do I need to use The Loop on pages (inside page.php etc)?
- Determining Slug Before and After Edit
- Automatically create pages in a post based on number of words
- Static posts page with home.php
- Set number of article per number of page
- Pagination for Pages and Posts
- How to restore permanently trash page? [closed]
- Custom Blog Post Page
- Creating a Page of Posts
- Private Posts/Pages & Search
- White Blank Page when Updating and Publishing Page/Post
- Posts vs. Pages
- Can’t get the_content of the parent page from its single post?
- post-page: reference to parent page?
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- Why content_arr[‘extended’] removes paragraph tags?
- page.php showing loop of posts and not page content
- Add Word Limit to Posts
- How to include the latest post of a specific category on a matching page
- post categories
- Post categories to pages
- Integrate OpenStreetMap on WordPress
- What’s the best way to render Visual Composer in posts, not pages?
- Second comments section for one post/page
- 404 error on default post type and default taxonomy fronted page
- Overwrite posts/pages via import
- Auto-realod with new posts // Ajax call
- Is there a way to specify an extra class for a post or page with no title?
- Display Posts on Custom Page
- 2 dynamic sidebars registered, not showing up
- How to make default “Privacy Policy Page” a normal page?
- How to detect when admin user is on the All Posts page?
- Total number of posts in query (category/tag/author/search results/main page…)
- Custom Permalink Structure for Pages & Posts
- Getting a “404 Not Found” error when “Preview Changes” is clicked
- WordPress 302 Redirect to Random Product/Post/Page
- New Posts and Pages Won’t Save
- My Custom Post Type Still Using index.php
- Post/page title to permalink transformation – what is behind the scenes?
- Would a “hub” page work better as a page or a post?
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Page of posts made to look like homepage
- How to link post titles on page A to its posts on page B?
- Different post views for different category views
- Changing permalink of WordPress
- Permanently deleted posts still exist
- Create a List of Widgets, where each widget holds three attributes
- Change published date and time using SQL query for page in every 5 hour
- Is there a way to know when a page has been updated and do some action only once?
- Please help a newbie with blog page issue?
- Added a ACF field to custom page and want the results to show as a column in admin
- Deleted page still shows and is showing posts archive
- How to create page with post content in it?
- Put page on Archived statut after end of publication date
- post and page and custom post type
- Single Sidebar; multiple templates! How?
- calling pages instead of posts
- WordPress display page information rather than post
- Post Category link is same with Page link
- WordPress for business site
- Is it possible to query a category with specified posts?
- How do I set content in my pages so that it remains permanent while blog posts are added below?
- Permalink base only for posts
- WordPress URL question
- Any difference betweenn posts and pages for one page?
- Theme does not respect spaces between paragraphs in pages
- Show only top 3 posts from 3 categories in order on home page
- My blog “page” used to show a list of posts, but now it’s just showing the page content?
- Bulk replacing content of multiple pages/posts?
- how to change the permalink to a specific location?
- One of my posts is displayed as page
- get next/previous post name
- Get post title of faulty link on 404 error page
- Get current post’s child page?
- The next_posts_link() works only with original $wp_query
- I need to create a page or post hierarchy
- Home page: using custom fields for posts and pages
- The loop: more posts than I want to fit on one page
- Automatically delete default posts and pages on theme install?
- How do I add an article to specific page?
- how to show all type of author posts in author page (SOLVED)
- custom post type single page template not working
- Insert Shortcode exactly at the end of the content
- How to find the page of specific post?
- WordPress Page Column Problem [closed]
- What function does the loop of displaying posts?
- Automatically search and replace link in content (pages/posts)?
- How to remove slug from CPT correctly?