你可以先试试这个。
1. 更改此<span class="id_53">Display Post Image</span>
至<span class="id_53" data-id="53">Display Post Image</span>
2. 创建您的js文件
$(function () {
// click event example
$(\'.id_53\').on(\'click\', getThumb);
// call the ajax
function getThumb() {
$.post( \'http://path/wp-content/themes/your-theme/ajax-file.php\' , \'my_id=\'+$(this).attr(\'data-id\') , showThumb );
}
// get image source
function showThumb(e) {
$(\'#img_in\').style({\'background-image\':e});
}
});
3. 创建ajax文件。php
// for external files
include( \'../../../wp-load.php\' );
// get your variable
$my_id = intval( $_POST[\'my_id\'] );
// get thumbnail ID
$thumb_id = get_post_thumbnail_id( $my_id );
// get path of thumbnail
$img = wp_get_attachment_image_src( $thumb_id, \'full\' );
echo $img[0];