• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Use Same Image For All Jetpacks Related Posts

This code displays the same image for all related posts featured images so the image you add as a featured image on single posts isn’t displayed for related posts.

Here’s an example of what Jetpacks related posts displays before adding the code:

default

And here’s an example showing how each related post uses the same image.

jetpack-related-posts

Change the path to your image in the code and add to your child themes functions file:

function jeherve_custom_image( $post_id, $args ) {
 
        $permalink = get_permalink( $post_id );
        $url = apply_filters( 'jetpack_photon_url', 'http://example.com/wp-content/uploads/2200/10/wpsites.png' );
      
        return array( array(
            'type'  => 'image',
            'from'  => 'custom_fallback',
            'src'   => esc_url( $url ),
            'href'  => $permalink,
        ) );
}
add_filter( 'jetpack_images_get_images', 'jeherve_custom_image', 10, 2 );

You can also add a default image to related posts when none added.

Jetpack

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.