WordPress.org

Ready to get started?Download WordPress

Forums

Attachment.php File Question (1 post)

  1. newstoob
    Member
    Posted 7 years ago #

    Ok I haven't had any luck finding an answer to this problem, hopefully someone might have a clue.

    I've stripped a lot of code out of the attachment.php page and this is what I have:

    <?php if (have_posts()) : the_post(); ?>
    
    <?php $attachment_link = get_the_attachment_link($post->ID, true); ?>
    <?php $_post = &get_post($post->ID); ?>
    
    				<?php echo $attachment_link; ?>
    
    	<?php else: ?>

    The problem is that it displays the wrong attachments at times. I found out that it looks as if when posts have the same image beginning file name (for instance photo1-file.jpg) as another post, it is displaying the image of the other post. The post and filenames are completely different but I guess WordPress cuts off the filename.

    Examples:

    /this-is-a-sample-post/image1-file/
    /another-sample-post/image1-file/

    If you need to see a live site example I'll be glad to provide anymore info. This problem is bugging the heck out of me and it is probably something simple to fix.

    Thanks in advance!

Topic Closed

This topic has been closed to new replies.

About this Topic