• I have a new site to show off my photography:
    https://mumford-photo.com/wordpress/

    the point of this site is to publish my photoshoots as posts so clients can download the images. but I want to be able to choose if an image on the attachment page should link to the original (hi-res) image, or not be linked.

    If there was a conditional php statement that said:

    “if this post has category 25, then link to original”

    that would solve it. Can anyone help? I’m not a php guy. Category 25 is my hidden client category, so I only want that category to link to the hi res.

    my image.php file has this code:

    <p class=”attachment”>ID); ?>”><?php echo wp_get_attachment_image( $post->ID, ‘medium’ ); ?></p>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter photocurio

    (@photocurio)

    [edit] this is the code that is in my image.php, not whats above.
    <p class="attachment"><a href="<?php echo wp_get_attachment_url($post->ID); ?>"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a></p>

    Thread Starter photocurio

    (@photocurio)

    taking a whack at this, i changed the above to the code below:

    <?php if (is_category('25')) echo '<a href="', wp_get_attachment_url($post->ID), '">'; else { echo ''; } ?>
    				<?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?>
    				<?php if (is_category('client')) echo '</a>'; else { echo ''; } ?>

    now the image appears, but it will not link to the high res file. i also tried
    if (is_category('client'))
    client being the name of the category. no change.

    Thread Starter photocurio

    (@photocurio)

    maybe my problem is that attachments don’t have categories. i was assuming an attachment would inherit the category of the post it is attached to.

    i think this is so because i can’t see the category in the page source. if image.php treats all images alike with no categorization, or tags, that would make it hard to make some attachment pages behave differently from others. at least all image pages have to be the same. or am I missing something?

    an example attachment page is:
    https://mumford-photo.com/wordpress/2010/04/bridges/01_mumford/

    I’ve tried the code that’s posted here: https://www.ads-software.com/support/topic/340547?replies=7#post-1529656 but am having trouble with the categories after I edit any of the posts: it stays with the original category and not the updated one

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘attachment page that links/does not link to original?’ is closed to new replies.