Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter klahla

    (@klahla)

    Alright. Case closed.
    Thank you Yaost and Linkdex for providing logic, but ended up writing everyting on my own.

    For those seeking the same thing: it is hard to have their box work with a random custom form, as it was constructed to work with the admin-side form. Yet is still possible to through their text-check functions in the above mentioned files, and see how it works. If you know php even at mid-to-low level, I believe you will be able to understand and re-rewrite what you need.

    I was working on front-end submission form and encounted a similar issue. Then understood how and why it works this way.

    Code looked something like this:

    if ( ... ) { $pstatus = "post"; }
           else { $pstatus = "draft"; }
    
    $new_post = array( ...
      'post_status' => $pstatus );
    $post_id = wp_insert_post($new_post);
    $link = get_permalink($post_id);
    echo $link;

    Here is the deal.

    When you submit post as a DRAFT,
    admin/editor can change the permalink before it is ever posted.
    The post slug ($post->post_name;) simply does not exist yet.
    So returning “?page_id=” is the only option wordpress has.

    If you submit post as a POST,
    then everything works perfectly as expected.

    Hope it helped.

Viewing 2 replies - 1 through 2 (of 2 total)