Support » Fixing WordPress » If.. then.. else with images

  • I’m not a programmer, but I really thought this would work. Want to write the following if.. then.. else.. statement:

    -The file is the name of the post and is in the uploads directory
    file exists
    tell me it exists
    tell me it doesn’t

    For some reason the code below outputs “the blog url” and then says “the file doesn’t exist”… when it does.

    Any help would be greatly appreciated!!



    $url = ‘/wp-content/uploads/’ . get_the_ID();
    $image_file = get_the_title();
    $full_url = bloginfo(‘url’) . $url . ‘/’ . $image_file;

    if (file_exists($full_url)) {
    echo “The file exists”;
    } else {
    echo “The file does not exist”;

  • The topic ‘If.. then.. else with images’ is closed to new replies.