Grabbing thumbnail url with raw code
-
Hi,
I am using the rawcode to print out an ul and list items with the post title and url. I need to figure out how to grab the thumbnail url. Can anyone assist?
function labnol_related_shortcode( $atts ) { $related_posts = ""; if ( class_exists( 'Jetpack_RelatedPosts' ) && method_exists( 'Jetpack_RelatedPosts', 'init_raw' ) ) { $related = Jetpack_RelatedPosts::init_raw() ->set_query_name( 'jetpackme-shortcode' ) ->get_for_post_id( get_the_ID(), array( 'size' => 3 ) // How many related posts? ); if ( $related ) { foreach ( $related as $result ) { $related_post = get_post( $result[ 'id' ] ); $url = get_permalink($related_post->ID); $title = $related_post->post_title; $img = $related_post->img; $related_posts .= " <li><img width='75' height='75' src='" . $img . "' class='attachment-related-small scale='0'><h4><a href='" . $url . "'>$title</a></h4></li> "; } $related_posts = ' <ul>' . $related_posts . '</ull>'; } } return $related_posts; } /* Create a new shortcode for Jetpack related posts */ add_shortcode( 'labnol_related', 'labnol_related_shortcode' );</ul>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Grabbing thumbnail url with raw code’ is closed to new replies.