get_posts() return NULL using a custom plugin and add_submenu_page() with Post Type

Question

Inside a custom plugin and using add_submenu_page() for custom post type I want to display one post.
As the other post_type I use get_posts($the_id, $arr_params) to get information about it, except in this case where it return NULL.
The corresponding ID exist in database .

the creation of this add_submenu_page() :

add_submenu_page( null , 'Modify Organization', 'Modify Organization','manage_options', 'edit-org','atv_edit_org');

The url of this custom post page is:

https://website.com/wp-admin/edit.php?post_type=org_post_type&page=edit-org&id=1998

So, using get_posts():

global $pagenow;
if ( $pagenow == 'edit.php' && $_GET['page'] == 'edit-org'):
//include_once(ABSPATH . 'wp-includes/pluggable.php');

$post_id = $_GET['id'];
$args_org_post = array('post_type' => 'org_post_type', 'post_status' => 'draft');
$data_post = get_post($post_id, $args_org_post);
var_dump($data_post);

it return `NULL

0
imagIne 2 weeks 2023-11-19T16:10:24-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse