Title: Permalinks are not being set while using wp_insert_post
Last modified: December 10, 2020

---

# Permalinks are not being set while using wp_insert_post

 *  Resolved [rajpanchani](https://wordpress.org/support/users/rajpanchani/)
 * (@rajpanchani)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/permalinks-are-not-being-set-while-using-wp_insert_post/)
 * Hi there,
 * My permastructure is : %brand%/%product%
 * brand taxonomy is custom for the product.
 * I am adding post by wp_insert_post.
    $post_id = wp_insert_post( $args );
 * After insert, I run following.
    $value = “Rolex”; wp_set_object_terms( $post_id,
   array($value), $slug, true );
 * Then file attached.
    But my permalink is not including Rolex in the product link.
   When I regenerate, it fix the brands.
 * Is there any hook or code that need to be added after this?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/permalinks-are-not-being-set-while-using-wp_insert_post/#post-13770797)
 * Hi [@rajpanchani](https://wordpress.org/support/users/rajpanchani/),
 * to generate the permalinks again you will need to directly access the global 
   with the uris array:
 *     ```
       global $permalink_manager_uris;
   
       $permalink_manager_uris[$post_id] = Permalink_Manager_URI_Functions_Post::get_default_post_uri($post_id);
       update_option('permalink-manager-uris', $permalink_manager_uris);
       ```
   
 * Best regards,
    Maciej

Viewing 1 replies (of 1 total)

The topic ‘Permalinks are not being set while using wp_insert_post’ is closed to
new replies.

 * ![](https://ps.w.org/permalink-manager/assets/icon.svg?rev=2625166)
 * [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/permalink-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/permalink-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/permalink-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/permalink-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/permalink-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/permalinks-are-not-being-set-while-using-wp_insert_post/#post-13770797)
 * Status: resolved