• Resolved markupgeek

    (@markupgeek)


    Hello,
    I have to insert post status based on condition. if record has “active” field with value “t” then post status should be publish and if record has “active” field with value “f” then post status should be draft. how can i do this.
    Can it be done by using xpath of post status then how

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @markupgeek

    I see that we helped out with this via our ticket system. Here was the solution for anyone else that’s curious:

    1) Pass the “active” element to a PHP function in the “Post Status” field inside the import: [my_set_status({active[1]})] (see screenshot and documentation).

    2) Save the code in the Function Editor:

    function my_set_status( $active ) {
    	return ( $active == 't' ) ? 'publish' : 'draft';
    }

    That’s it.

    Note: if you’re updating existing posts using this method, be sure to only update the post status – see screenshot.

    Thread Starter markupgeek

    (@markupgeek)

    Hello,

    Nice. problem solved. Thanks for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to use xpath in post status of wpalliimport plugin’ is closed to new replies.