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]
- function deactivate_plugins does not exist
- what’s the meaning of the field wp_capabilities in table wp_usermeta
- Adding more options to the instance of an image. (Attachment Display Settings)
- What is wrong with using add_option with Multisite instead of add_blog_option in a plugin
- Trouble with Transient API when W3TC is activated [closed]
- WordPress Terminology Options Vs. Settings
- How to modify post content before writing to database?
- $wp_filesystem returns NULL. What are the dependencies?
- set_sale_price in WooCommerce [closed]
- Synchronize custom post type tags with WordPress default post type tags
- jquery document ready function not being called [closed]
- How do I add a filter to wp_list_categories() to make links nofollow?
- How to hook into publish post events in wordpress 4.7.5
- What is the best way to embed an JS App in a WordPress Page?
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- $reverse_top_level works the opposite way according to Codex?
- How to serve different thumbnails/images depending on users browser/platform
- How to export post meta with images in wordpress
- Parse form values before sending to options.php
- My WordPress plugin cannot load my JavaScript file
- Add Minimum Dimensions Text to Featured Image
- Show error message after exception handled
- How to connect my wordpress plugin to a remote database securely?
- How to create a backend for a custom theme?
- admin_post equivalent for guest user?
- When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- I am trying to make a page in the admin section similar to the appearance of the Profile page for users
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- unregister_setting() vs delete_option() for plugin update
- add_filter img_caption_shortcode not implemented
- How to add Plugin functionality in WordPress Frontend Menus
- in_array function Problem
- Best practice for plugin: always detect admin-ajax call?
- Adding another field to user table
- How to hide page links from theme menu
- Brainstorm – Slow Query from Plugin Need to Speed It Up
- How to add text editor in plugin menu?
- wp_schedule_event not executing function call, even with add_action
- How to query a nested field in wordpress api using _fields param
- function add custom fields to media gallery
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Add quick edit functionnality to plugin table
- using wordpress acf shortcods in tables goes outside the table
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- remove different admin menu for specific users
- add pagination to wp_remote_get
- Not able to Update database while creating a custom module
- How to load css file after a certain css file
- Shortcode from a plugin not working
- Deactivate Other Incompatible Plugin Upon Activation
- How to make auto installer Plugin?
- Can’t get query string in ajax call
- Pass results of custom query to loop – when writing a plugin
- user can login from single account detail from multiple locations(computer) at the same time [closed]
- WP Cron registers hook without any action (does not call the function)
- WP Job Manager – Show recent jobs as cards
- Elementor Top-Bar