I’m posting this as another solution for you and its based on the page id
/*
$post_id - The ID of the post you'd like to change.
$status - The post status publish|pending|draft|private|static|object|attachment|inherit|future|trash.
*/
function change_post_status($post_id,$status){
$current_post = get_post( $post_id, 'ARRAY_A' );
$current_post['post_status'] = $status;
return wp_update_post($current_post);
}
So once you have this function you can use it with the page id of the page you created:
$ads_page = get_option('mjj_smart_ads_page');
$old_ads_page = change_post_status($ads_page,'draft');
update_option('mjj_old_smart_ads_page', $old_ads_page);
Related Posts:
- Add Password Generator on password protected page
- Get page content using slug
- Change the_title() of a page dynamically
- How to edit the properties of a page programmatically?
- How to change post status in hook?
- How to trap “Publish” button to check for meta box validation?
- Pages 404 in wordpress
- How to create a dynamic page based on form data with a plugin?
- Use an empty page to build custom plugin output
- Is it possible for a plugin to register a page template file?
- Dropdown list of pages to get page id to store in plugin options
- Calling a function from functions.php in custom page/ blog post
- How do I approach removing menu items on the fly based on settings in my plugin?
- Set a specific page as 404 – not found via my own plugin
- Create a Page via plugin
- Can I set a timer for pages to be published?
- Secure Pages Best Practice
- Plugin generated virtual pages
- ECHO Executing 4 Times In Head
- WordPress pages are not published due to External database connection with WPDB class
- Create page (not the post type) dynamically
- WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title
- Multiple array for post_content on plugin activation
- How to list all images used on a specific page?
- Create fixed static pages
- How to create archive page to add in menu
- Load specific page when a custom URL is hit
- Plugin frontend page design irrespective of the theme used
- Custom non-template page on front end fails to render
- How do I control the list of Pages an author can see?
- How to add conent (text) to Add New pages form of admin in WordPress
- auto create only 1 wp page in activate custom plugin
- problem with blank page
- Tracing dashboard publish settings from input form in WordPress
- Create pages for authors
- Plugin SVN folder structure
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Using a Page Template Not in Theme
- Bulk post approval and publishing doesn’t work
- Generating Multiple Divi Pages from Database
- Problem with Owl Carousel, infinite loop [closed]
- Is there a way to decide from init whether we are on a certain backend page?
- Can a WordPress plugin add read-only pages?
- Plugin Development – Multilangual – Different pages
- Simple plugin don’t display content
- Screenshots on plugin page taken old [closed]
- How to translate wordpress backend to another language
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- How to create two custom post types when plugin is activated?
- How to hide page links from theme menu
- Get post thumbnail in WP_Query
- Brainstorm – Slow Query from Plugin Need to Speed It Up
- How can I save a password securely as a settings field
- Unexpected T_FUNCTION
- How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?
- Plugin settings are saving but the fields
- Plugin can’t be activated [closed]
- How to make a cronjob type plugin
- How to avoid conflict of plugin style and theme style?
- How do I debug an error that a plugin is causing?
- Adding an external stylesheet to a plugin
- Ajax +wordpress onClick link redirect to new page and create html content
- WP_NAV_MENU filter targets all menus
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- Get section of input passed to the sanitize_callback
- wp_ prefix changed. What is the way to change so any prefix is understood?
- If $var is empty, return 404.
- How to replace settings in WordPress plugin from a theme
- Forward an old url rewrite scheme to a new one?
- Use options to control jQuery plugin
- Save temporary registration data
- Including template in shortcodes
- Activate / Deactivate plugin
- Is there a WordPress plugin to design WebGL? [closed]
- $wpdb in php 5.5
- how to display a string in admin_notices hook from a class plugin
- How to add a route?
- Create an user on external database
- Should I put my plugin javascript inline?
- Adding Dynamic Stylesheet
- Form submission to another page returning 404 error [duplicate]
- Resize not resizing images with Capitial extension like JPG
- Redirect returning users to a certain page?
- Is there any way to hide page from dashboard (all pages list) OR navbar from plugin function?
- Pagination not working with custom wp_query
- Get Posts by IDs (optionally)
- Passing values between enclosing and enclosed shortcodes
- I need to modify drafts using custom data from database and then publish it
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- How to get the number of pages when paginating comments?
- How does “Your comment is awaiting moderation” work?
- why does get_option( ‘home’ ) not work while using in plugin [closed]
- Toolbar Hidden in a Virtual Page
- Plugin architecture to pull from API & create dynamic content on WP site?
- Undefined is_user_logged_in() error with Plugin Query code
- Add code to template dynamically
- Thickbox in Plugin settings page?
- Plugin Options not saving options and doesn’t work
- How can my plugin display a populated new post window
- How to localize data array in plugin’s option page