• Resolved ticketsibiza

    (@ticketsibiza)


    Hi,

    Thanks for the great plugin.

    When importing items, I’d like to reuse the newly created post slug url as a custom field for that same item.

    For example, if the slug for one of my imported items ends up being:

    mysite.com/post/this-slug

    I’d like to have that entire URL as the key for one of my other custom fields.

    Is it possible to do this within WP import? The only other workaround I can think of is to create the slug within my CSV, but I’m not sure of the regex used to create the urls.

    Thank you.

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

    (@wpallimport)

    Hi @ticketsibiza

    You could use some custom code and our pmxi_saved_post hook to do that: http://www.wpallimport.com/documentation/advanced/action-reference/. Here’s an example snippet that you can modify as needed:

    add_action( 'pmxi_saved_post', 'my_save_url_to_custom_field', 10, 1 );
    
    function my_save_url_to_custom_field( $id ) {
    	$custom_field = 'my_cool_field'; // change this to your custom field
    	update_post_meta( $id, $custom_field, get_the_permalink( $id ) );
    }
    Thread Starter ticketsibiza

    (@ticketsibiza)

    That’s great, I will give it a go. Thank you for the support!

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

The topic ‘Re-use post slug as custom field’ is closed to new replies.