• Resolved bushidopt

    (@bushidopt)


    Hi, I have a 8 year old wordpress website and recently moved from YARPP to Jetpack Related Posts.

    I have a little problem, some old posts do not have a featured image and related posts shows text instead of an image, so how can i prevent Related Posts from showing related posts without thumbnail. ex. http://i.imgur.com/Pwl3hjT.jpg

    I have two options, i think…

    1- Somehow mess with the code and do not allow showing related posts without thumbnail

    2- Trough a filter only allow to show related posts that were posted after the year 2010

    In YARPP i placed a default image that were shown if the related post did not have a featured image, is that possible in Jetpack Related Posts?

    Tks

    https://wordpress.org/plugins/jetpack/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    The easiest solution is probably to add a default image if no image can be found in the post. You can follow the instructions here to do so:
    http://jetpack.me/2013/10/15/add-a-default-fallback-image-if-no-image/

    2- Trough a filter only allow to show related posts that were posted after the year 2010

    That’s also possible. You can specify a range to select Related Posts from. For example, to only display posts that are less than a year old:

    function jetpackme_related_posts_past_year_only( $date_range, $post_id ) {
        $date_range = array(
            'from' => strtotime( '-1 year' ),
            'to' => time(),
        );
        return $date_range;
    }
    add_filter( 'jetpack_relatedposts_filter_date_range', 'jetpackme_related_posts_past_year_only' );

    1- Somehow mess with the code and do not allow showing related posts without thumbnail

    That’s also possible, although a bit more complicated. You should be able to sort Related Posts returned and exclude posts without any image thanks to the jetpack_relatedposts_returned_results filter (#). However that won’t work if you’re already adding a default image to all posts.

    I hope this helps.

    Thread Starter bushidopt

    (@bushidopt)

    Thanks Jeremy, I added a default image, it was easy.

    I suggest adding “add a default image if no image can be found” to the “Customize Related Posts” page (http://jetpack.me/support/related-posts/customize-related-posts/)beacuse i searched everywhere and didn’t find http://jetpack.me/2013/10/15/add-a-default-fallback-image-if-no-image/ or my google-fu is weak 😉

    Thanks again, you guys are the best .

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    I suggest adding “add a default image if no image can be found” to the “Customize Related Posts” page

    Good idea. I just added a new section. Thanks for the suggestion!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude post without thumbnail in Related Posts’ is closed to new replies.