• pixelstud

    (@pixelstud)


    Is there a way to hide post titles, so only the thumbnail links to the permalink (with title, full image, post etc.)? Is there a way to do this globally and/or per post?

    I’d like to have just a grid of thumbnail images as links to posts, instead of the more common title and thumbnail. The titles in my case are hashtags.

    -> https://www.pixelstud.com

    PS
    I was able to find a way, In functions.php to link all post thumbnails to the permalink using:

    // 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;
    }`

    Any ideas would be appreciated!
    Jayson

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Depending on how your theme outputs titles, you may be able to accomplish this with CSS, for example title { display: none }.

    The other way is to alter the template responsible so that the title is never output to begin with. You can maybe just comment out the responsible code, for example <?php /* the_title() */ ?>

    When you have custom code or alter templates, you should create a child theme to contain your changes so they are not overwritten when the theme is updated.

    Thread Starter pixelstud

    (@pixelstud)

    Hi there
    Thanks for the response. I tried the css but no luck with that.
    For the second method are you suggesting modifying the functions.php file?

    Yes! I have created a child theme and have been working within it.

    Moderator bcworkz

    (@bcworkz)

    Depending on the parent theme, there may be a way through functions.php, but no, I was thinking probably header.php. Copy the parent’s file to your child and alter as necessary.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide post titles, so only the thumbnail links to the permalink’ is closed to new replies.