WordPress.org

Forums

Adamos
[resolved] Slider Link to Post (4 posts)

  1. cren1985
    Member
    Posted 1 year ago #

    Hi Ossie,

    instead of using the headline of the black box in the slider to redirect to the post the slider image refers to I wanted the slider image itself to serve as link to the post.

    I removed the corresponding values in the header.php to remove the box in the slider but I have no clue how to use the slider image as link.

    I would greatly appreciate your help.

  2. Template Express
    Member
    Theme Author

    Posted 1 year ago #

    hello cren,

    in the custom-home.php remove the <a href="<?php the_permalink() ?>"> </a> from the title and excerpt and add it to the thumbnail

  3. cren1985
    Member
    Posted 1 year ago #

    Thank you for your help, I got what I needed by adding this to my functions.php

    // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
    
    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
    	$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    
    	return $html;
    }
  4. Template Express
    Member
    Theme Author

    Posted 1 year ago #

    excellent - good luck with your website

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.