On this page
WP_Importer::count_imported_posts( string $importer_name, string $blog_id ): int
Return count of imported permalinks from WordPress database
Parameters
$importer_namestring Required$blog_idstring Required
Return
int
Source
File: wp-admin/includes/class-wp-importer.php. View all references
public function count_imported_posts( $importer_name, $blog_id ) {
global $wpdb;
$count = 0;
// Get count of permalinks.
$meta_key = $importer_name . '_' . $blog_id . '_permalink';
$sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key );
$result = $wpdb->get_results( $sql );
if ( ! empty( $result ) ) {
$count = (int) $result[0]->cnt;
}
return $count;
}
Related
Uses
| Uses | Description |
|---|---|
| wpdb::get_results() wp-includes/class-wpdb.php | Retrieves an entire SQL result set from the database (i.e., many rows). |
| wpdb::prepare() wp-includes/class-wpdb.php | Prepares a SQL query for safe execution. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_importer/count_imported_posts