Tagged: avia, preview, preview not working
-
AuthorPosts
-
February 25, 2016 at 2:34 pm #589105
Page preview is not working when using the Avia framework, not even with the fix found here: https://kriesi.at/support/topic/no-preview-with-enfold-in-dev-website/
I devised a better fix, see filter below (copy / paste it in your functions.php file)
/* Fix an issue where previewing a page does not show modified changes when using the Avia framework */ function avia_preview_fix($content) { if (is_preview()) { /* The latest preview for this author is *probably* the one we want: - post_parent = 0 for all previews - post_type = revision for all previews - post_status = whatever the current status of the current post / page being previewed is - author = always the current logged in user - sort by descending date since the most recent one is the one we need - this way we need to only retrieve one post */ $wpq = new WP_Query(array( 'post_parent' => 0, 'post_type' => 'revision', 'post_status' => 'any', // change this maybe to the post status of the post being previewed? 'author' => get_current_user_id(), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 1 )); // double check if there are any posts if ($wpq->posts) { // overwrite content with the latest preview content $content = $wpq->posts[0]->post_content; } } return $content; } add_filter('avia_builder_precompile', 'avia_preview_fix', 99, 1 );
Feel free to bestow us with a bit more free support in return ;-)
- This topic was modified 8 years, 9 months ago by kracht12.
February 25, 2016 at 2:44 pm #589121Hey kracht12!
thanks a lot for sharing your solution with us.
Cheers!
AndyFebruary 25, 2016 at 3:38 pm #589189He Andy,
You’re welcome!
My solution depends on the autosave feature that seems to be called each time you press the preview button. However it seems that sometimes saving the preview takes more time than loading the preview so you might end up with either an older preview or no preview (the current version). It usually does provide better results compared to using get_the_content() since that sometimes returns a preview made by another user that previously edited the page, or no preview at all (the current version again). Also, post_parent is better omitted, I saw instances (in the database) where post_parent was either 0 or the current post_ID so that is a bit buggy / random.
I hope you find a use for this fix, however I haven’t seen anyone else having a problem with previews since the support topic from december 2013 so your solution seems to working fine for most users.
February 29, 2016 at 5:04 pm #590941Hi!
thanks for the additional info.
Let us know in a new ticket if you have some more questions related to the theme. We are happy to assist you.
Best regards,
Andy -
AuthorPosts
- You must be logged in to reply to this topic.