Run plugins only on certain pages
I want to use my personal plugin only in some pages. If I remove the add_action function ('the_content', 'my_plugin_content'); the plugin does not show me the content of the other pages that are not in in_array ();
function my_plugin_content($content){
global $post; global $wp; global $wpdb;
$page =array('page1', 'page2','page3');
$current_page = $wp-request;
if(in_array($current_page, $page))
{
$old_content=$post-post_content;
$sql = "UPDATE wp_posts SET post_content = '' WHERE ID = $post-ID";
$wpdb-get_results($sql);
include_once(plugin_dir_path( __FILE__ ).'loaders/loaders.php');
$obj = new Loader;
$content.=$obj-controller($current_page);
$my_post = array();
$my_post['ID'] = $post-ID;
$my_post['post_content']=$content;
wp_update_post($my_post);
}
}
add_action('the_content', 'my_plugin_content');
Topic custom-content activation pages customization plugins Wordpress
Category Web