WordPress.org

Ready to get started?Download WordPress

Forums

attachment page that links/does not link to original? (5 posts)

  1. photocurio
    Member
    Posted 4 years ago #

    I have a new site to show off my photography:
    http://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>

  2. photocurio
    Member
    Posted 4 years ago #

    [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>

  3. photocurio
    Member
    Posted 4 years ago #

    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.

  4. photocurio
    Member
    Posted 4 years ago #

    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:
    http://mumford-photo.com/wordpress/2010/04/bridges/01_mumford/

  5. tgiokdi
    Member
    Posted 4 years ago #

    I've tried the code that's posted here: http://wordpress.org/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

Topic Closed

This topic has been closed to new replies.

About this Topic