WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Make all images in posts a href to the_permalink() (9 posts)

  1. henrylemmon
    Member
    Posted 1 year ago #

    I managed to surround the_content() in the loop.php whith a href pointing to the_content and it made the text in the post a link to the single post, but I just want to make the image in the body of the post to be a link not the text.

    I allready have the featured image pointing to its respective post, but not the image that would be inserted into the body of the post.

    thank you
    henrylemmon>

  2. Jay Hoffmann
    Member
    Posted 1 year ago #

    Just use the_permalink to link to the post within the loop. So it would look something like:

    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

    Just make sure you close the link with </a> before you introduce the text into the loop.

  3. henrylemmon
    Member
    Posted 1 year ago #

    I allready have that done for the featured image I am talking about the image that would be placed into the body of the post. see code..
    http://wordpress.pastebin.ca/2251622

  4. Jay Hoffmann
    Member
    Posted 1 year ago #

    So you'd like to isolate the image that is in the body of the post and make that a link to the post it is an excerpt of?

  5. henrylemmon
    Member
    Posted 1 year ago #

    Yes, would that be practical?

  6. Jay Hoffmann
    Member
    Posted 1 year ago #

    What might be more practical is to use a plugin like Multiple Post Thumbnails (http://wordpress.org/extend/plugins/multiple-post-thumbnails/) and set up a second post thumbnail that you can then incorporate into the loop and link to the page more easily.

    I don't know if there's a way to do it using the image from the body.

  7. henrylemmon
    Member
    Posted 1 year ago #

    Yea you are right, and if we could do anything to the image how would we target it in css say if we want to set a border,

    so just add

    `add_image_size( 'small', 75, 75, true);
    add_image_size( 'medium', 280, 280, true);
    add_image_size( 'large', 616, 462, true);`

    into the functions.php and then

    <a href="<?php the_permalink(); ?>"
    	<?php the_post_thumbnail('small')?>
    </a>

    into the loop and choose featured image in the edit post I think that may do what the plugin does.
    Thank you.
    henrylemmon>

  8. henrylemmon
    Member
    Posted 1 year ago #

    Thank You

  9. henrylemmon
    Member
    Posted 1 year ago #

    I am using my front page as a static page and my blog is named blog. how can I run a conditional to check if the blog page is loaded so I can exclude one of the category's from displaying in the blog page?

    <?php
    	if ( is_home()) {
    	query_posts($query_string . '&cat=-17&posts_per_page=3' );
    	}
    ?>

    the above code is in the codex but it does not work for me, it just performs the same query over and over and offers me older posts -> and newer posts -> links and the older post link leads to the 404, mabye the query_string var is not storing the prev query info?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.