I am using taxonomy and I need to get attached image to taxonomy. I have renamed my wp-content folder. After that I cannot retrieve the image path. I used

<?php bloginfo('url'); ?>/renamed-folder/uploads/<?php echo get_post_meta(get_my_taxonomy_fields($set->term_id, 'upload_image'), '_wp_attached_file', true); ?>

So, my image code is

 <img src="<?php bloginfo('url'); ?>/renamed-folder/uploads/<?php echo get_post_meta((get_my_taxonomy_fields($set->term_id, 'upload_image'), '_wp_attached_file', true); ?>" alt="<?php echo $set->name;  ?>" />

How can I get the taxonomy attached image path..?

  • Taxonomies have not images attached to them, ¿How do you attach them? Are you using some plugin? You can use wp_get_attachment_image_src() to get the URL of any image if you know its ID; or get_attached_fiile() if you need the path in the file system of your server.
    – cybmeta
    Nov 13, 2016 at 10:14

1 Answer 1


If your going to reference the uploads directory use https://developer.wordpress.org/reference/functions/wp_upload_dir/

$upload_dir = wp_upload_dir(); // Array of key => value pairs
    $upload_dir now contains something like the following (if successful)
    Array (
        [path] => C:\path\to\wordpress\wp-content\uploads\2010\05
        [url] => http://example.com/wp-content/uploads/2010/05
        [subdir] => /2010/05
        [basedir] => C:\path\to\wordpress\wp-content\uploads
        [baseurl] => http://example.com/wp-content/uploads
        [error] =>
    // Descriptions
    [path] - base directory and sub directory or full path to upload directory.
    [url] - base url and sub directory or absolute URL to upload directory.
    [subdir] - sub directory if uploads use year/month folders option is on.
    [basedir] - path without subdir.
    [baseurl] - URL path without subdir.
    [error] - set to false.

echo $upload_dir['path'] . '<br />';
echo $upload_dir['url'] . '<br />';
echo $upload_dir['subdir'] . '<br />';
echo $upload_dir['basedir'] . '<br />';
echo $upload_dir['baseurl'] . '<br />';
echo $upload_dir['error'] . '<br />';

$upload_url = ( $upload_dir['url'] );
$upload_url_alt = ( $upload_dir['baseurl'] . $upload_dir['subdir'] );

// Now echo the final result
echo $upload_url . '<br />'; // Output - http://example.com/wp-content/uploads/2010/05

// Using year and month based folders, the below will be the same as the line above.
echo $upload_url_alt . '<br />'; // Output - http://example.com/wp-content/uploads/2010/05

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.