• Is there a way to call just the post’s upload directory?

    So call just this -> “uploads/2018/09”

    without the image name instead of this:

    “uploads/2018/09/image_name.jpg”

    So just the path?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Howdy!

    You could potentially use dirname( $filename ) to get that. Can you provide a bit more detail as to what you are attempting to do?

    Thread Starter djdavedawson

    (@djdavedawson)

    This did not work ??

    dirname( $filename )

    I have uploaded a vCard file to the media library for each individual post.

    I have a custom field where I put the file name in but need the full path to the vCard. Since the image path corresponds to publish date.

    Like this -> “uploads/2018/09/image_name.jpg”

    I have since made something that works ok

    $vcard = get_post_meta($post->ID, “vcard”, true);
    $url = explode(‘/’, get_the_post_thumbnail_url($post->ID)); array_pop($url); $vcardpath = implode(‘/’, $url) . “/”. $vcard;

    But there has to be something more elegant ??

    • This reply was modified 6 years, 4 months ago by djdavedawson.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get post image directory url’ is closed to new replies.