WP_Importer::count_imported_posts() WordPress Method

The WP_Importer::count_imported_posts() method can be used to return the number of posts that have been imported by the current WP_Importer instance. This can be useful for debugging or for displaying progress information to the user.

WP_Importer::count_imported_posts( string $importer_name, string $blog_id ) #

Return count of imported permalinks from WordPress database


Parameters

$importer_name

(string)(Required)

$blog_id

(string)(Required)


Top ↑

Return

(int)


Top ↑

Source

File: wp-admin/includes/class-wp-importer.php

	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;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.