Wordpress Plugin Development tutorial from scratch (Part 11) Delete Wordpress page by Plugin
In this video session i have explained about Delete Wordpress page by Plugin, #WordpressTutorialsPoint #WordpressLearnersHub #WordpressCustomizations #LearnWordpressStepbyStep #WordpressBySanjay Steps to do this task: #1: Save Post Id of page first while creating Wordpress page. #2: Call deactivation/Uninstall hook #3: Delete Wordpress page by getting ID of that page First we need Create Post code, =============== For creating page while plugin activates please have a look this video session to get closer concept about it, https://www.youtube.com/watch?v=oL8ffxggYZY function create_page(){ // code for create page $page = array(); $page['post_title']= "Custom Plugin Online Web Tutor"; $page['post_content']= "Learning Platform for Wordpress Customization for Themes, Plugin and Widgets"; $page['post_status'] = "publish"; $page['post_slug'] = "custom-plugin-online-web-tutor"; $page['post_type'] = "page"; $post_id = wp_insert_post($page); // post_id as return value add_option("custom_plugin_page_id",$post_id); // wp_options table from the name of custom_plugin_page_id } register_activation_hook(__FILE__,"create_page"); Documentation of 'wp_insert_post' : https://developer.wordpress.org/reference/functions/wp_insert_post/ Calling Deactivation/Uninstall hook =================== It works when we deactivate our plugin, register_deactivation_hook(__FILE__,"deactivate_table"); It works when we delete our plugin register_uninstall_hook(__FILE__,"deactivate_table"); and Finally we have to attach with Action hook, register_activation_hook(__FILE__,"create_page"); Finally call a function by action hook which deletes the page ===================== function deactivate_table(){ global $wpdb; // step1: we get the id of post means page // delete the post from table $the_post_id = get_option("custom_plugin_page_id"); if(!empty($the_post_id)){ wp_delete_post($the_post_id,true); } } To create table while plugin activates, Click here to see: https://www.youtube.com/watch?v=nzRyFF95jXI Delete table while plugin deactivates/Uninstalls, Click here to see: https://www.youtube.com/watch?v=sa28dHu6YCA SOCIAL : =============== Subscribe : https://www.youtube.com/channel/UCB2flCo-gW6RhpVVXySqcMg FACEBOOK : https://www.facebook.com/onlinewebtutorhub/ TWITTER: https://twitter.com/owthub BLOG: https://onlinewebtutorhub.blogspot.in/ RECOMMENDATION: =============== 1. Some knowledge of PHP, HTML for this video series 2. How to Install Wordpress: https://www.youtube.com/watch?v=MREgql9jmf0 3. register_deactivation_hook: https://developer.wordpress.org/reference/functions/register_deactivation_hook/ Also you can learn Wordpress Custom =============== Theme Development: https://www.youtube.com/watch?v=MREgql9jmf0&list=PLT9miexWCpPV9WxY_QG3qxUGKzw54LboW Widget Development: https://www.youtube.com/watch?v=ZSbdYG1svV8&list=PLT9miexWCpPUgibUXDZ7JP1j3U-m61U8m Tags =============== online web tutor, profotech solutions, wordpress plugin development from scratch in hindi, wordpress plugin development from scratch in easy steps, wordpress plugin development, wordpress plugin development in easy steps, plugin development in wordpress from scratch in hindi, plugin development in wordpress by online web tutor, plugin development in wordpress tutorials from scratch in hindi, plugin theme development tutorials in hindi, plugin development tutorials in hindi, owt tuts, online web tutorials, Thanks Online Web Tutor Keep learning and Sharing :) -~-~~-~~~-~~-~- Please watch: "Learn backbone.js tutorial from scratch" https://www.youtube.com/watch?v=HOAU-nfy5Sc -~-~~-~~~-~~-~-
Download
0 formatsNo download links available.