Skip to content

Instantly share code, notes, and snippets.

@gaambo
Last active June 8, 2020 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaambo/f25d6b25c417cb622c929f984e608a5f to your computer and use it in GitHub Desktop.
Save gaambo/f25d6b25c417cb622c929f984e608a5f to your computer and use it in GitHub Desktop.
WP Revisionary Preview Wrong Thumbnail Image
<?php
public function fltPreviewLink($url, $_post = false) {
global $post, $revisionary;
if (!empty($_REQUEST['wp-preview']) && !empty($_post) && !empty($revisionary->last_autosave_id[$_post->ID])) {
$url = remove_query_arg('_thumbnail_id', $url);
// EDIT: get thumbnail id instead of setting thumbnail id to autosave post id
$thumbnailId = get_post_meta($revisionary->last_autosave_id[$_post->ID], '_thumbnail_id', true);
$url = add_query_arg('_thumbnail_id', $thumbnailId, $url);
} elseif ($post && rvy_is_revision_status($post->post_status)) {
$url = rvy_preview_url($post);
}
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment