Getting duplicate page when activating my plugin

If no result is found, $wpdb->get_row will return NULL not false https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Row You are using add_action(‘init’, ‘gallerypage’); so it runs on every load. You should be using register_activation_hook so that it only runs when the plugin is activated. https://codex.wordpress.org/Function_Reference/register_activation_hook Try using get_page_by_path() to check if the page already exists. Then you won’t need to use … Read more

How to filter get_adjacent_post()?

Well it wasn’t too hard after some perspective. public function get_adjacent_post_mod($where){ if (is_single()){ global $wpdb, $post; if ( get_post_status ( ) == ‘private’ ) { $where = str_replace( “AND ( p.post_status=”publish” OR p.post_status=”private” )”, “AND p.post_status=”private””, $where ); return $where; } else { $where = str_replace( “AND ( p.post_status=”publish” OR p.post_status=”private” )”, “AND p.post_status=”publish””, $where … Read more