Uses
| Uses | Description |
|---|---|
| wp-includes/wp-db.php: wpdb::get_results() | Retrieves an entire SQL result set from the database (i.e., many rows). |
| wp-includes/wp-db.php: wpdb::prepare() | Prepares a SQL query for safe execution. |
Returns array with imported permalinks from WordPress database
(string) (Required)
(string) (Required)
(array)
File: wp-admin/includes/class-wp-importer.php
public function get_imported_posts( $importer_name, $bid ) {
global $wpdb;
$hashtable = array();
$limit = 100;
$offset = 0;
// Grab all posts in chunks.
do {
$meta_key = $importer_name . '_' . $bid . '_permalink';
$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );
$results = $wpdb->get_results( $sql );
// Increment offset.
$offset = ( $limit + $offset );
if ( ! empty( $results ) ) {
foreach ( $results as $r ) {
// Set permalinks into array.
$hashtable[ $r->meta_value ] = intval( $r->post_id );
}
}
} while ( count( $results ) == $limit );
// Unset to save memory.
unset( $results, $r );
return $hashtable;
}
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_importer/get_imported_posts