English 中文(简体)
Wordpress> 创建“分类”儿童类别(目录=1)
原标题:Wordpress > Create category as child of "uncategorized" (catid=1)

我在我的职责中翻了一封信。 php 报告说,对我的主题要求的若干类别进行核查,如果这些类别不在现场,就会发现这些类别。

if(!get_cat_ID( my-category )){wp_create_category( my-category );}

我需要以两种方式修改这一文字......

首先,我需要设立这一类别,使其母类别为“分类”类别(或同上1)。

第二,如果已经存在这种类别,但其母子不是id,我需要这样做。

最佳回答
问题回答

首先,如果存在类别,则进行测试。 如果是的话,则使用get_ category_ 即:_ 即:,以获得现有类别的父母。

$parentID = get_category_parents(my-category-ID, false);

其次,second公认论点 of wp_create_ category()是你希望指定为母类的类别。

if(!get_cat_ID( my-category )){wp_create_category( my-category ,parent category ID);}

第三,如果确实存在这一类别,你可使用wp_update_term()来改变其属性。

wp_update_term( $term_id, $taxonomy, $args );




相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签