WP_Importer::count_imported_posts
Returns count of imported permalinks from WordPress database.
Method of the class: WP_Importer{}
No Hooks.
Returns
Int.
Usage
$WP_Importer = new WP_Importer(); $WP_Importer->count_imported_posts( $importer_name, $blog_id );
- $importer_name(string) (required)
- .
- $blog_id(string) (required)
- .
Notes
- Global. wpdb.
$wpdbWordPress database abstraction object.
WP_Importer::count_imported_posts() WP Importer::count imported posts code WP 7.0
public function count_imported_posts( $importer_name, $blog_id ) {
global $wpdb;
$count = 0;
// Get count of permalinks.
$meta_key = $importer_name . '_' . $blog_id . '_permalink';
$result = $wpdb->get_results(
$wpdb->prepare(
"SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s",
$meta_key
)
);
if ( ! empty( $result ) ) {
$count = (int) $result[0]->cnt;
}
return $count;
}