Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $crm_names = array();
- $posts = array();
- $crms = get_field( 'crms', 'option' );
- foreach ( $crms as $crm ) {
- $crm_names[] = $crm['name'];
- }
- $args = array(
- 'nopaging' => true,
- 'post_type' => 'documentation',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'documentation_category',
- 'field' => 'slug',
- 'terms' => 'integrations',
- ),
- ),
- );
- $integrations = get_posts( $args );
- $did = 0;
- foreach ( $crm_names as $crm_name ) {
- foreach ( $integrations as $integration ) {
- $title = 'Connect ' . $integration->post_title . ' to ' . $crm_name;
- if ( ! empty( get_page_by_title( $title, OBJECT, 'connect' ) ) ) {
- continue;
- }
- $args = array(
- 'post_title' => $title,
- 'post_status' => 'publish',
- 'post_type' => 'connect',
- );
- $post_id = wp_insert_post( $args );
- update_post_meta( $post_id, 'crm_name', $crm_name );
- update_post_meta( $post_id, 'plugin_name', $integration->post_title );
- update_post_meta( $post_id, 'plugin_docs_id', $integration->ID );
- $did++;
- }
- }
- echo 'Did ' . $did;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement