[resolved] wp_update_post stuck in loop? (1 post)

  1. iamronen
    Posted 4 years ago #

    I've been scratching my head for a few days over this ... and simply can't figure it out.

    I have a custom post-type save function hooked into "save_post". In it I am updating some post-meta fields and also generating a title and slug. In the code I am using the wp_update_post functin to save the title and slug I generated. That's when there seems to be a problem. The post IS updated however the browser continues to be busy until a timeout error occurs.

    The code is qualified twice to prevent an infinite loop:
    my_save_function() {

    global $post;

    if ( get_post_type( $post ) == 'myposttype' ) {

    // meta updates go here

    if ($post->post_title != $generatedpostitle) {
    $post->post_title = $generatedposttitle;
    $post->post_name = $generatedpostslug;

    if I comment out the wp_update_post the code runs fine ... with it the browser hangs. Similar code is working in a different post-type on the same website without any problems.

    any suggestions would be much appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic