I'm trying to get the file path of an attachment so that its uploaded to vimeo directly from a custom_post_type
in Wordpress
but $attachment_id
is returning a null
. How can i get the $attachment_id
?
global $attachment_id;
$filepath = get_attached_file( $attachment_id );
$url = 'https://api.vimeo.com/me/videos';
$args = array(
'type'=>'pull',
'link'=>'the_link',
);
$response_vimeo = wp_safe_remote_post ( $url, $args);
There are many possibilities depending on the situation you are trying to execute this code in. One possibility is
$post = get_post();
$attachment_id = $post->ID;
Or maybe the id is coming in from a $_POST
or $_GET
variable. Try adding print_r($_POST); print_r($_GET);
and see what you get if you're submitting a form or creating a post.