• So what I’m trying to do is take my attachment page, and link the picture to the site. Right now it’s linking to the next page in the series using this code:

    <a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment">

    The way I can think of is by putting in a custom field into the blog post say site_url, but using something like this doesn’t work:

    <?php echo get_post_meta($post->ID, "site_url", true); ?>
    because the attachment doesn’t really appear to be part of the blog.

    My next suggestion was to put the URL in say the image description and call the URL like I call the title:

    <?php echo esc_attr( get_the_title() ); ?>

    but is that really the best way to go? Plus I can’t seem to find the code to call the image description anyway.

    Any help on this would be great

Viewing 4 replies - 1 through 4 (of 4 total)
  • Clarification: Do you want the image to link back to the front page, or to the specific blog post that the image is attached to?

    Thread Starter vanillaice

    (@vanillaice)

    In the attachment page, I’d like the image to link to a specified URL.

    I’d like to have the path go:

    Index (blog post) -> Attachment (image) -> Affiliate Site

    thanks ??

    Then if you want to go the custom field route, you’d be able to load the blog post the image is attached to using $post->post_parent e.g.

    <?php echo get_post_meta($post->post_parent, "site_url", true); ?>

    Thread Starter vanillaice

    (@vanillaice)

    Worked beautifully, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Attachment Page Mod’ is closed to new replies.