Bug: Live Editor Problem with secondary loops
Hi there,
I found a problem with the live-editor (which btw. is genius).
The thing is… I built a custom widget, which outputs the contents of some posts of a custom post type. These custom posts are filled using the pagebuilder too.
I output the contents within a secondary loop using the_content(). This works perfectly fine on normal view, but creates an infinite loop on live preview as you run a filter on ‘get_post_meta’ which replaces the custom post meta with the contents from $_POST without checking if the request is the actual currently displayed page/post.
So the error is in the file:
/siteorigin-panels/inc/live-editor.php
I came up with a hotfix which isn’t beautiful but works:
function siteorigin_panels_live_editor($value, $post_id, $meta_key){
$queriedPost = get_queried_object();
if($meta_key == 'panels_data' && current_user_can( 'edit_post', $post_id ) && !empty( $_POST['live_editor_panels_data'] ) && is_a($queriedPost, 'WP_Post') && $post_id == $queriedPost->ID ) {As you can see all I do is compare the given $post_id with the queried-object’s ID if and only if the queried object is of type ‘WP_Post’.
So it would be great if you either add my solution to the plugin or fix this issue in another way.
This would be really awesome!
Thx a lot,
David
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
1Hi David
Sorry for the late reply here.
Awesome to hear you’re enjoying the Live Editor. There’s a lot I’d still like to add to that interface to make it a little more front-end-editorish, but it’s definitely a powerful tool.
This is the kind of fix I’d like to implement. Is there anywhere I could get a copy of your widget to test things out? I’ll log this on Github once I get that from you.
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.