Upload a CSV file with keyword and URL data:

$row[0], 'url' => $row[1]); } fclose($handle); } internal_link_maker_create_links($data); } } // Create internal links from the CSV data function internal_link_maker_create_links($data) { $link_count = count($data); $current_count = 0; foreach ($data as $row) { $post_id = internal_link_maker_get_post_id_by_keyword($row['keyword']); if ($post_id) { $post = get_post($post_id); $content = $post->post_content; $new_content = str_ireplace($row['keyword'], '' . $row['keyword'] . '', $content); $post_data = array( 'ID' => $post_id, 'post_content' => $new_content ); wp_update_post($post_data); internal_link_maker_log_link($row['url']); } $current_count++; printf( 'Added %d of %d links
', $current_count, $link_count ); flush(); ob_flush(); sleep(1); // Sleep for 1 second } } // Get the post ID that contains a given keyword function internal_link_maker_get_post_id_by_keyword($keyword) { $args = array( 'post_type' => 'any', 's' => $keyword, 'posts_per_page' => 1 ); $query = new WP_Query($args); if ($query->have_posts()) { $post_id = $query->posts[0]->ID; return $post_id; } else { return false; } } // Log the URLs of the pages where internal links have been created function internal_link_maker_log_link($url) { $links = get_option('internal_link_maker_links', array()); $links[] = $url; update_option('internal_link_maker_links', $links); } // Display the results of the internal linking process function internal_link_maker_results() { $links = get_option('internal_link_maker_links', array()); ?>

URL