本文整理汇总了PHP中wp_create_category函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_create_category函数的具体用法?PHP wp_create_category怎么用?PHP wp_create_category使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_create_category函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elaplugin_activate
function elaplugin_activate()
{
$terms_to_add = array("European Language Portfolio");
//create those categories if they don't already exist
foreach ($terms_to_add as $trm) {
if (term_exists($trm) == 0) {
wp_create_category($trm);
}
}
}
示例2: create_category
public function create_category()
{
require_once ABSPATH . 'wp-admin/includes/taxonomy.php';
if (isset($_POST['addcat'])) {
$newcat = $_POST['newcat'];
if (wp_create_category($newcat)) {
$this->alert = 'New Category Created';
}
}
}
示例3: property_detail_content
function property_detail_content($content)
{
if (get_post_meta(get_the_ID(), 'property_id', true) != '' && get_post_meta(get_the_ID(), 'bapi_last_update', true) < time() - 3600 * 60 * 24) {
remove_filter('save_post', 'update_post_bapi');
wp_update_post(mod_post_builder($propid, get_the_ID()));
update_post_meta(get_the_ID(), 'bapi_last_update', time());
wp_set_post_terms(get_the_ID(), wp_create_category(get_option('property_category_name')), 'category');
add_filter('save_post', 'update_post_bapi');
}
bapi_search_page_body($content);
return $content;
}
示例4: create_categories
private function create_categories($post)
{
$course_category = get_post_meta($post->ID, "course_category_id", true);
if ($course_category == "") {
$course_category = wp_create_category($post->post_title);
add_post_meta($post->ID, "course_category_id", $course_category, true);
}
$discussion_category = get_post_meta($post->ID, "course_discussion", true);
if ($discussion_category == "") {
$discussion_category = wp_create_category(__("discussions"), $course_category);
add_post_meta($post->ID, "course_discussion", $discussion_category, true);
}
return array($course_category, $discussion_category);
}
示例5: wp_create_categories
/**
* Create categories for the given post.
*
* @since 2.0.0
*
* @param array $categories List of categories to create.
* @param int $post_id Optional. The post ID. Default empty.
* @return List of categories to create for the given post.
*/
function wp_create_categories($categories, $post_id = '')
{
$cat_ids = array();
foreach ($categories as $category) {
if ($id = category_exists($category)) {
$cat_ids[] = $id;
} elseif ($id = wp_create_category($category)) {
$cat_ids[] = $id;
}
}
if ($post_id) {
wp_set_post_categories($post_id, $cat_ids);
}
return $cat_ids;
}
示例6: create_my_cat
function create_my_cat()
{
if (file_exists(ABSPATH . '/wp-admin/includes/taxonomy.php')) {
require_once ABSPATH . '/wp-admin/includes/taxonomy.php';
$loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1));
while ($loop->have_posts()) {
$loop->the_post();
global $post;
$post_slug = $post->post_name;
if (!get_cat_ID($post_slug)) {
wp_create_category($post_slug);
}
}
wp_reset_query();
}
}
示例7: create_categories
private function create_categories($post)
{
$categories = array();
$course_category = get_post_meta($post->ID, "course_category_id", true);
if ($course_category == "") {
$course_category = wp_create_category($post->post_title);
add_post_meta($post->ID, "course_category_id", $course_category, true);
}
array_push($categories, $course_category);
$assignment_category = get_post_meta($post->ID, "course_module_assignments", true);
if ($module_category == "") {
$assignment_category = wp_create_category("Assignments", $course_category);
add_post_meta($post->ID, "course_module_assignments", $assignment_category, true);
}
array_push($categories, $assignment_category);
return $categories;
}
示例8: create_categories
private function create_categories($post)
{
$categories = array();
$course_category = get_post_meta($post->ID, "course_category_id", true);
if ($course_category == "") {
$course_category = wp_create_category($post->post_title);
add_post_meta($post->ID, "course_category_id", $course_category, true);
}
array_push($categories, $course_category);
$student_category = get_post_meta($post->ID, "course_students", true);
if ($quiz_category == "") {
$student_category = wp_create_category("Students", $course_category);
add_post_meta($post->ID, "course_students", $student_category, true);
}
array_push($categories, $student_category);
return $categories;
}
示例9: activation
/**
* Create the new Genealogy Update category.
* Schedule an update of the TNG RSS feed.
*
* @author Nate Jacobs
* @date 9/11/14
* @since 1.0
*/
public function activation()
{
wp_create_category($this->tng_rss_category);
/**
* Filter the scheduled recurrence event time.
*
* @author Nate Jacobs
* @date 11/1/14
* @since 1.6
*
* @param string The cron interval.
*/
$schedule = apply_filters('tng_wp_rss_post_schedule', 'daily');
if (!wp_next_scheduled('tng_wp_rss_update')) {
wp_schedule_event(time(), $schedule, 'tng_wp_rss_update');
}
}
示例10: create_categories
private function create_categories($post)
{
$categories = array();
$course_category = get_post_meta($post->ID, "course_category_id", true);
if ($course_category == "") {
$course_category = wp_create_category($post->post_title);
add_post_meta($post->ID, "course_category_id", $course_category, true);
}
array_push($categories, $course_category);
if (isset($_POST['module'])) {
$module_category = get_post_meta($post->ID, "course_module_" . $_POST['module'], true);
if ($module_category == "") {
$module_category = wp_create_category(stripslashes($_POST['module_name']), $course_category);
add_post_meta($post->ID, "course_module_" . $_POST['module'], $module_category, true);
}
array_push($categories, $module_category);
}
return $categories;
}
示例11: make_category
function make_category($slug, $parent = null)
{
//既存カテゴリをすべて取得
$categories = get_categories($args);
//print_r($categories);
$flag = 0;
foreach ($categories as $cat) {
if ($slug == $cat->name) {
$flag = 1;
$cat_id = $cat->cat_ID;
break;
}
}
if ($flag != 1) {
//重複無ければ
return wp_create_category($slug, $parent);
} else {
return $cat_id;
}
}
示例12: wpse_set_defaults
function wpse_set_defaults($blog_id)
{
global $json_api;
switch_to_blog($blog_id);
$id = 'json_api_controllers';
$required_controllers = explode(",", "categories,posts,user,projects,attachments");
$available_controllers = $json_api->get_controllers();
$active_controllers = explode(',', get_option($id, 'core'));
$action = "activate";
foreach ($required_controllers as $controller) {
if (in_array($controller, $available_controllers)) {
if ($action == 'activate' && !in_array($controller, $active_controllers)) {
$active_controllers[] = $controller;
} else {
if ($action == 'deactivate') {
$index = array_search($controller, $active_controllers);
if ($index !== false) {
unset($active_controllers[$index]);
}
}
}
}
}
$value = implode(',', $active_controllers);
$option_exists = get_option($id, null) !== null;
if ($option_exists) {
update_option($id, $value);
} else {
add_option($id, $value);
}
// Remove the default post & page
wp_delete_post(1, true);
wp_delete_post(2, true);
// Remove the first comment
wp_delete_comment(1, true);
// add default categories
wp_create_category("Project");
wp_create_category("Document");
restore_current_blog();
}
示例13: explode
$mycats = explode(",", $a[0]["mycats"]);
echo "{$appear_pk} <br>";
$tags = "";
if ($a[0]["show_nm2"]) {
$tags .= "," . $a[0]["show_nm2"];
}
if ($a[0]["show_nm3"]) {
$tags .= "," . $a[0]["show_nm3"];
}
/*
// add show to categories if not a category yet
$showcat = wp_create_category($shownm, 161);
if ($showcat) $mycats[] = $showcat;
*/
// add PERSON to categories if not a category yet
$personcat = wp_create_category($peoplenm, $peoplecat);
if ($personcat) {
$mycats[] = $personcat;
}
$title = $peoplenm . " on " . $shownm . " on " . $dt2;
// 'ID' => $postfk,
// Create post object
$my_post = array('post_type' => "appearance", 'post_title' => $title, 'post_content' => "", 'post_status' => 'publish', 'post_author' => 1, 'post_category' => $mycats, 'tags_input' => $shownm . "," . $peoplenm . $tags, 'post_date' => $dt);
print_r($my_post);
$postid = wp_insert_post($my_post);
update_post_meta($postid, '_wp_page_template', 'single-appear.php');
$q = "UPDATE appearances SET appear_post = {$postid} WHERE appear_pk = {$appear_pk}";
$conn->query($q);
echo $q;
echo "<hr>";
// break;
示例14: die
die('-1');
}
$names = explode(',', $_POST['newcat']);
if (0 > ($parent = (int) $_POST['newcat_parent'])) {
$parent = 0;
}
$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
$checked_categories = array_map('absint', (array) $post_category);
$popular_ids = wp_popular_terms_checklist('category', 0, 10, false);
foreach ($names as $cat_name) {
$cat_name = trim($cat_name);
$category_nicename = sanitize_title($cat_name);
if ('' === $category_nicename) {
continue;
}
$cat_id = wp_create_category($cat_name, $parent);
$checked_categories[] = $cat_id;
if ($parent) {
// Do these all at once in a second
continue;
}
$category = get_category($cat_id);
ob_start();
wp_category_checklist(0, $cat_id, $checked_categories, $popular_ids);
$data = ob_get_contents();
ob_end_clean();
$add = array('what' => 'category', 'id' => $cat_id, 'data' => str_replace(array("\n", "\t"), '', $data), 'position' => -1);
}
if ($parent) {
// Foncy - replace the parent and all its children
$parent = get_category($parent);
示例15: test_terms_search
function test_terms_search()
{
$this->make_user_by_role('editor');
$name = rand_str(30);
$name_id = wp_create_category($name);
// search by full name
$filter = array('search' => $name);
$results = $this->myxmlrpcserver->wp_getTerms(array(1, 'editor', 'editor', 'category', $filter));
$this->assertNotInstanceOf('IXR_Error', $results);
$this->assertEquals(1, count($results));
$this->assertEquals($name, $results[0]['name']);
$this->assertEquals($name_id, $results[0]['term_id']);
// search by partial name
$filter = array('search' => substr($name, 0, 10));
$results2 = $this->myxmlrpcserver->wp_getTerms(array(1, 'editor', 'editor', 'category', $filter));
$this->assertNotInstanceOf('IXR_Error', $results2);
$this->assertEquals(1, count($results2));
$this->assertEquals($name, $results2[0]['name']);
$this->assertEquals($name_id, $results2[0]['term_id']);
}