WordPress.org

Ready to get started?Download WordPress

Forums

How can I make my featured images, clickable? (6 posts)

  1. muchacho79
    Member
    Posted 1 year ago #

    On my front page where it lists my posts, only the title is hyperlinked to get through to that post.

    How can I make it so that the featured image to the left is also clickable? Here is the code where I imagine the change will need to be made:

    <div class="wrap-post">
                    <?php $theme->hook('post_before'); ?>
    
                        <div <?php post_class('post clearfix'); ?> id="post-<?php the_ID(); ?>">
                        <?php $theme->hook('post'); ?>
    
                            <?php
                                if($theme->options['general']['featured_image'] && $theme->display('featured_image', $get_post_elements) && has_post_thumbnail())  {
                                    the_post_thumbnail(
                                        array($theme->get_option($theme->options['template_part'] . '_featured_image_width'), $theme->get_option($theme->options['template_part'] . '_featured_image_height')),
                                        array("class" => $theme->get_option($theme->options['template_part'] . '_featured_image_position') . " featured_image")
                                    );
                                }
                            ?>

    I assume I have to put this somewhere?

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

    Thanks in advance,

  2. Yes you would use <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

    Your code will look like this:

    <?php
    if($theme->options['general']['featured_image'] && $theme->display('featured_image', $get_post_elements ) && has_post_thumbnail() ) { ?>
        <a href="<?php the_permalink(); ?>">
        <?php the_post_thumbnail( array(
        $theme->get_option( $theme->options['template_part'] . '_featured_image_width'),
        $theme->get_option($theme->options['template_part'] . '_featured_image_height'),
        ),
     array(
     "class" => $theme->get_option( $theme->options['template_part'] . '_featured_image_position') . " featured_image",
     )
    ); ?></a>
    <?php } ?>
  3. muchacho79
    Member
    Posted 1 year ago #

    Hmmm, for some reason when I put that, the featured image disappears.

  4. smilingdogstudio
    Member
    Posted 1 year ago #

    I'm using the Hatch theme and looking for the same solution. Hatch doesn't display vertical images and relies heavily on the "Featured Image" function. An image displays twice if it is inserted into the post and used as the featured image.

  5. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    @smilingdogstudio - please start your own thread as your question/situation is not identical to the one in this thread.

  6. smilingdogstudio
    Member
    Posted 1 year ago #

    Thank you WPyogi - I didn't see in this thread where any theme was mentioned.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.