wp_create_nav_menu

Definition:
function wp_create_nav_menu( $menu_name ) {}

Create a Navigation Menu.

Parameters

  • string $menu_name: Menu Name

Return values

returns:Menu object on success|WP_Error on failure

Source code

function wp_create_nav_menu( $menu_name ) {

	return wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) );

}

3509

wp_create_category

Definition:
function wp_create_category( $cat_name, $parent = 0 ) {}

Parameters

  • unknown_type $cat_name
  • unknown_type $parent

Source code

function wp_create_category( $cat_name, $parent = 0 ) {

	if ( $id = category_exists($cat_name, $parent) )

		return $id;



	return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) );

}

3507

wp_create_categories

Definition:
function wp_create_categories($categories, $post_id = '') {}

Parameters

  • unknown_type $categories
  • unknown_type $post_id

Source code

function wp_create_categories($categories, $post_id = '') {

	$cat_ids = array ();

	foreach ($categories as $category) {

		if ($id = category_exists($category))

			$cat_ids[] = $id;

		else

			if ($id = wp_create_category($category))

				$cat_ids[] = $id;

	}



	if ( $post_id )

		wp_set_post_categories($post_id, $cat_ids);



	return $cat_ids;

}

3505

wp_count_terms

Definition:
function wp_count_terms( $taxonomy, $args = array() {}

Count how many terms are in Taxonomy.
Default $args is ‘hide_empty’ which can be ‘hide_empty=true’ or array(‘hide_empty’ => true).

Parameters

  • string $taxonomy: Taxonomy name
  • array|string $args: Overwrite defaults. See get_terms()

Return values

returns:How many terms are in $taxonomy

Source code

function wp_count_terms( $taxonomy, $args = array() ) {

	$defaults = array('hide_empty' => false);

	$args = wp_parse_args($args, $defaults);



	// backwards compatibility

	if ( isset($args['ignore_empty']) ) {

		$args['hide_empty'] = $args['ignore_empty'];

		unset($args['ignore_empty']);

	}



	$args['fields'] = 'count';



	return get_terms($taxonomy, $args);

}

3503

wp_count_posts

Definition:
function wp_count_posts( $type = 'post', $perm = '' ) {}

Count number of posts of a post type and is user has permissions to view.
This function provides an efficient method of finding the amount of post’s type a blog has. Another method is to count the amount of items in get_posts(), but that method has a lot of overhead with doing so. Therefore, when developing for 2.5+, use this function instead.

Parameters

  • string $type: Optional. Post type to retrieve count
  • string $perm: Optional. ‘readable’ or empty.

Return values

returns:of posts for each status

Source code

function wp_count_posts( $type = 'post', $perm = '' ) {

	global $wpdb;



	$user = wp_get_current_user();



	$cache_key = $type;



	$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";

3501