• Al

    (@rvillarremaxnyccom)


    <?php $query->rewind_posts(); while($query->have_posts()) : $query->the_post(); if(has_post_thumbnail()) :  ?>
    		<?php echo wp_get_attachment_image(get_post_thumbnail_id(), 'slider-large', false, array('class' => 'slide')) ?>

    Basically, I’ve been trying to figure out how to permalink the slider images to point to their respective posts. Can anyone help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • If you are constructing slider frames using wp post data, you are going to need to make the src for the image = the_permalink(). Something like:

    <div class="slider">
        <img src="<?php echo the_permalink();?>">
    </div>

    Does that help?

    Thread Starter Al

    (@rvillarremaxnyccom)

    Unfortunately no. Thanks for the attempt. This is the lines of code I’m dealing wit right now, but all it creates the slider, but it does not link to anywhere. I’ve been fumbling with this for a few days now

    <div class="post-titles">
    			<?php while($query->have_posts()) : $query->the_post(); if(has_post_thumbnail()) : $post_count++; ?>
    				<a>"><?php the_title() ?></a>
    			<?php endif; endwhile; ?>
    		</div>

    [Moderator Note: Please post code between backticks (not single quotes) or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    <a href="<?php echo the_permalink(); ?>">Link or Image</a>

    Will add a link, you can replace “Link or Image” with an image such as:

    <a href="<?php echo the_permalink(); ?>"><img src="path/to/slider/image.jpg"></a>

    or the post featured image:

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

    sdellow, what you put is correct. I was putting the_permalink() as the image source instead of the link in the <a tag. That was garbled on my part.

    Thank you for putting up a correct response.

    Al, please let me know if this is any better. Thanks.

    <?php $query->rewind_posts();
    	while($query->have_posts()) :
    		$query->the_post();
    		if(has_post_thumbnail()) :  ?>
    			<?php echo '<a href="' . the_permalink() . '">' . wp_get_attachment_image(get_post_thumbnail_id(), 'slider-large', false, array('class' => 'slide')) . '</a>' ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Making Home Slider Images Have Permalinks’ is closed to new replies.