• Resolved matteo.boria

    (@matteoboria)


    First of all: thanks for the plugin.
    Now the problem: calls to standard WP function wp_update_post() reset any related field content. I.e. the Simple Page Ordering plugin reset all related fields every time you re-order (with drag&drop) your pages!

    I think the problem is method save() (lines 118-130 in current version). The condition:
    if (!isset($_POST['related-posts']) || empty($_POST['related-posts'])) is always true if the update is a low level update, via wp_update_post(). The line above delete the meta.

    Probably the code should delete the content destination only if the $_POST[‘related-post’] is set (and empty).

    if(isset($_POST['related-posts'])){
    				if (empty($_POST['related-posts'])) :
    					delete_post_meta($id, 'related_posts');
    				else :
    					update_post_meta($id, 'related_posts', $_POST['related-posts']);
    				endif;
    			}

    Ciao;
    Matteo

    https://wordpress.org/plugins/related/

Viewing 1 replies (of 1 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Thank you.

    It’s fixed in 1.4.2

    After fixing it, it seemd the meta key was still broken for the affected posts. After deleting them in the database it could be set again.

Viewing 1 replies (of 1 total)
  • The topic ‘Related meta disappears after wp_update_post()’ is closed to new replies.