WordPress.org

Support

Support » Themes and Templates » [Resolved] Link image to post from main page when using Image format

[Resolved] Link image to post from main page when using Image format

  • I would like to know how to link the image in a post using the “Image” post format to go to the post instead of the image. I know how to write HTML and CSS and tweak PHP… there is some function of Pinboard that strips out any HTML on the image, so if I hand code the link on the image to go to the post, it will not work. I cannot figure out where this function is however. Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • In functions.php, I found:

    $image = wp_get_attachment_image_src( $attachment->ID, 'full' ); ?>
    				<figure>
    					<a>" title="<?php the_title_attribute(); ?>" class="colorbox"  rel="attachment">
    						<?php echo wp_get_attachment_image( $attachment->ID, 'image-thumb' ); ?>
    					</a>
    				</figure>

    and took out the link, to make it:

    $image = wp_get_attachment_image_src( $attachment->ID, 'full' ); ?>
    				<figure>
    
    						<?php echo wp_get_attachment_image( $attachment->ID, 'image-thumb' ); ?>
    
    				</figure>

    Now I just need to figure out how to make the image go to the post. pinboard_post_link maybe?

    Figured it out! Just had to use "<?php the_permalink() ?>">

    So the final code in functions.php is:

    $image = wp_get_attachment_image_src( $attachment->ID, 'full' ); ?>
    				<figure>
    
    						<a href="<?php the_permalink() ?>"><?php echo wp_get_attachment_image( $attachment->ID, 'image-thumb' ); ?></a>
    
    				</figure>

    Hi, Patrick. Can you give us the link to your site so we can see what you’ve done and how it looks? Thanks 🙂

    Sorry it took so long to respond, I forgot to check my e-mail 🙂

    Thanks for the link. Your site looks good! Very clean but colorful.

    Patrick, i did same thing but it didnt work out. Could you help me, i also want to link main picture to the post itself. My site is http://www.bezbashny.com
    I changed preferences to way you wrote but there is a picture box after click. Thanks

    Also i am curious how to make readmore button on the main page. Because i can go inside the post only after clicking header. Thanks

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    If you need support for your issue, Sleepything, it would be best to start up a new thread.

    Hi sleepything, sorry it has taken me so long to respond. The only thing I can think of is that there are two instances of <?php echo wp_get_attachment_image( $attachment->ID, 'image-thumb' ); ?> in functions.php — so either change both of them to <a href="<?php the_permalink() ?>"><?php echo wp_get_attachment_image( $attachment->ID, 'image-thumb' ); ?></a> or just change the on that you didn’t change.

    I have been searching for this solution for ages! Thanks Patrick!

    Bump.

    And this doesn’t seem to work for me. Also, the site on your link doesn’t seem to do what you say it does. I’m guessing some update screwed it up for you, Patrick?

    Is there anyone who has a working fix for this. It’s quite strange to me that the standard is for the pics not to lead to the post but…

    Thanks

    Hi herrkarlson,
    Thanks for pointing that out, it seems an update screwed it up. I reinserted my fix and it’s working again. I wish I knew why it’s not working for you. Give me some clues?

    I got it to work after removing “div.zoomed { zoom: 3; -moz-transform: scale(3); -moz-transform-origin: 0 0}” from style.css

    I guess it didn’t realized the window was at the bottom of the screen and therefore didn’t call the infiscroll function.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Resolved] Link image to post from main page when using Image format’ is closed to new replies.