• Resolved ldiorio

    (@ldiorio)


    I followed your code to programattically add a new pod to one of my POD collections. It creates the new pod, but does not publish the post. Can you please explain what I missed? Thank you!

    add_shortcode( ‘add_pod’, ‘addPod’);
    function addPod()
    {
    $pod = pods( ‘cust’ );
    $data = array(
    ‘post_title’=>’Bill Bailey’,
    ‘cname’ => ‘Bill Bailey’,
    ‘phone’ => ‘222-333-4444’,
    ’email’ => ‘bb@aol.com’
    );
    $new_id = $pod->add( $data );
    return $new_id;

    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paul Clark

    (@pdclark)

    To publish a post, you need to set post_status to publish.

    It’s also generally a bad idea to write to the database with a shortcode. This would cause a database write on every page view.

    Thread Starter ldiorio

    (@ldiorio)

    Thank you! “post_status” solved the issue. And the shortcode was just to create an easy test. It is not my use case.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘question about add()’ is closed to new replies.