[Resolved] Blog archive page: featured images linking

Home Forums Support [Resolved] Blog archive page: featured images linking

Home Forums Support Blog archive page: featured images linking

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1376408
    ch1800

    Hi folks,

    Blog archive page: Is there a way to link the post’s featured image + the page title to the media (lightbox) instead of the corresponding blog page?

    PS: I’m already using this for randomizing them.

    Thanks and happy Sunday!

    #1377018
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You’d have to set up the lightbox part, but you may be able to filter the link of the featured image/title like this:

    add_filter( 'post_link', function( $link ) {
        if ( ! is_singular() && has_post_thumbnail() ) {
            return get_the_post_thumbnail_url();
        }
    
        return $link;
    } );

    Let me know ๐Ÿ™‚

    #1377361
    ch1800

    Excellent, works like a charm!
    Many thanks for this and the previous one for randomizing them that I also found here.

    I use those for creating a design portfolio, simply by using GP’s masonry layout for posts archives. No need of another plugin. Featured images are design screenshots in full height and details & links to the websites are in the excerpts.

    #1378206
    Tom
    Lead Developer
    Lead Developer

    Awesome, glad it worked! ๐Ÿ™‚

    #1665279
    ch1800

    Hi again about same topic: I would like to use the same snippet above that works fine for “all posts” but by adding a condition to apply only to a given post category, ex. all posts from category “abcd”.

    Would this be possible?

    Thanks!

    #1665420
    David
    Staff
    Customer Support

    Hi there,

    try changing:

    if ( ! is_singular() && has_post_thumbnail() ) {

    to:

    if ( ! is_singular() && has_post_thumbnail() && has_category('your-category') ) {

    #1665430
    ch1800

    Great, many thanks for your help!

    #1665440
    David
    Staff
    Customer Support

    You’re welcome

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.