<?php
add_action ( \'category_edit_form_fields\', \'addTitleFieldToCat\', 10, 2 );
function addTitleFieldToCat( $tag, $taxonomy ) {
$cat_title = get_term_meta( $tag->term_id, \'_pagetitle\', true );
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="cat_page_title"><?php _e(\'Category Page Title\'); ?></label></th>
<td>
<input type="text" name="cat_title" id="cat_page_title" value="<?php echo $cat_title ?>"><br />
<p class="description"><?php _e(\'Title for the category\'); ?></p>
</td>
</tr>
<?php
}
add_action ( \'edited_category\', \'saveCategoryFields\' );
function saveCategoryFields() {
if ( isset( $_POST[\'cat_title\'] ) ) {
update_term_meta( $_POST[\'tag_ID\'], \'_pagetitle\', $_POST[\'cat_title\'] );
}
}
用户@talk nerdy to me建议的代码修改-
https://wordpress.stackexchange.com/users/122776/talk-nerdy-to-me