WP_Importer::count_imported_posts

Advertisement

Summery Summery

Return count of imported permalinks from WordPress database

Syntax Syntax

WP_Importer::count_imported_posts( string $importer_name, string $bid )

Parameters Parameters

$importer_name

(Required)

$bid

(Required)

Return Return

(int)

Source Source

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

	public function count_imported_posts( $importer_name, $bid ) {
		global $wpdb;

		$count = 0;

		// Get count of permalinks.
		$meta_key = $importer_name . '_' . $bid . '_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 = intval( $result[0]->cnt );
		}

		// Unset to save memory.
		unset( $results );

		return $count;
	}

Advertisement

Advertisement

Leave a Reply