0

i'm just reseach wordpress for few days. But i don't know what keyword to reseach this problem:

I have 2 post module called hotel and room . In hotel page when i edit , it have a button to redirect to add new room in room module . this link is :

example.com/wp-admin/post.php?post_type=room&hotel_id=30

But when i edit a room , this link is:

example.com/wp-admin/post.php?post=31&action=edit

HOw can i add extra parameter to room edit to seperate which is room edit , which is hotel edit . Example:

example.com/wp-admin/post.php?post=30&action=edit   (hotel)
example.com/wp-admin/post.php?post=31&hotel_id=30&action=edit (room)

Can anyone give me a solution or keyword to research . Thanks for reading

1 Answer 1

0

The get_edit_post_link filter lets you modify that value. This is applied any time get_edit_post_link function is called, which admin uses, as well as themes on the front end.

function wpd_edit_post_link_filter( $link, $post_ID, $context ){
    if( 'room' == get_post_type( $post_ID ) ){
        $link = $link . '&fubar=baz';
    }
    return $link;
}
add_filter( 'get_edit_post_link', 'wpd_edit_post_link_filter', 10, 3 );

You can use the $post_ID to fetch info about that particular post, and get_current_screen might be helpful to decide when to apply the filter.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.