Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

Here's raw code for the DIY people.

/** Add New Field To Category **/
function extra_category_fields( $tag ) {
    $t_id = $tag->term_id;
    $cat_meta = get_option( "category_$t_id" );
?>
<tr class="form-field">
    <th scope="row" valign="top"><label for="meta-content"><?php _e('Landing Page Content'); ?></label></th>
    <td>
        <div id="catContent">
            <style type="text/css">.form-field input {width: auto!important;}</style>
            <?php wp_editor($cat_meta['content'], 'cat_landing', array(
                    'textarea_name' =>  'cat_meta[content]',
                    'textarea_rows' =>  15,
            )); ?>
        </div>
        <span class="description"><?php _e('Landing Page Content, Edit This Like You Would A Page.'); ?></span>
    </td> 
</tr>
<?php
}
add_action('category_edit_form_fields','extra_category_fields');  

/** Save Category Meta **/
function save_extra_category_fileds( $term_id ) {
    global $wpdb;
    if ( isset( $_POST['cat_meta'] ) ) {
        $t_id = $term_id;
        $cat_meta = get_option( "category_$t_id");
        $cat_keys = array_keys($_POST['cat_meta']);
            foreach ($cat_keys as $key){
            if (isset($_POST['cat_meta'][$key])){
                $cat_meta[$key] = $_POST['cat_meta'][$key];
            }
        }
        update_option( "category_$t_id", $cat_meta );
    }
}
add_action ( 'edited_category', 'save_extra_category_fileds');

With these you can actually do more, such as adding an ordering fieldadding an ordering field or whatever your heart desires.

In the action call you can change:

add_action('category_edit_form_fields','extra_category_fields'); to your specific

taxonomy by changing category to your taxonomy name as so:

add_action('YOUR-TAX-HERE_edit_form_fields','extra_category_fields');
add_action ( 'edited_YOUR-TAX-HERE', 'save_extra_category_fileds');

Finally to get your meta content you can use this:

$category_id = get_cat_ID();
if($category_id != 0){
    $cat_meta = get_option( "category_$category_id");
    echo apply_filters('the_content', $cat_meta['content']);
}

Here's raw code for the DIY people.

/** Add New Field To Category **/
function extra_category_fields( $tag ) {
    $t_id = $tag->term_id;
    $cat_meta = get_option( "category_$t_id" );
?>
<tr class="form-field">
    <th scope="row" valign="top"><label for="meta-content"><?php _e('Landing Page Content'); ?></label></th>
    <td>
        <div id="catContent">
            <style type="text/css">.form-field input {width: auto!important;}</style>
            <?php wp_editor($cat_meta['content'], 'cat_landing', array(
                    'textarea_name' =>  'cat_meta[content]',
                    'textarea_rows' =>  15,
            )); ?>
        </div>
        <span class="description"><?php _e('Landing Page Content, Edit This Like You Would A Page.'); ?></span>
    </td> 
</tr>
<?php
}
add_action('category_edit_form_fields','extra_category_fields');  

/** Save Category Meta **/
function save_extra_category_fileds( $term_id ) {
    global $wpdb;
    if ( isset( $_POST['cat_meta'] ) ) {
        $t_id = $term_id;
        $cat_meta = get_option( "category_$t_id");
        $cat_keys = array_keys($_POST['cat_meta']);
            foreach ($cat_keys as $key){
            if (isset($_POST['cat_meta'][$key])){
                $cat_meta[$key] = $_POST['cat_meta'][$key];
            }
        }
        update_option( "category_$t_id", $cat_meta );
    }
}
add_action ( 'edited_category', 'save_extra_category_fileds');

With these you can actually do more, such as adding an ordering field or whatever your heart desires.

In the action call you can change:

add_action('category_edit_form_fields','extra_category_fields'); to your specific

taxonomy by changing category to your taxonomy name as so:

add_action('YOUR-TAX-HERE_edit_form_fields','extra_category_fields');
add_action ( 'edited_YOUR-TAX-HERE', 'save_extra_category_fileds');

Finally to get your meta content you can use this:

$category_id = get_cat_ID();
if($category_id != 0){
    $cat_meta = get_option( "category_$category_id");
    echo apply_filters('the_content', $cat_meta['content']);
}

Here's raw code for the DIY people.

/** Add New Field To Category **/
function extra_category_fields( $tag ) {
    $t_id = $tag->term_id;
    $cat_meta = get_option( "category_$t_id" );
?>
<tr class="form-field">
    <th scope="row" valign="top"><label for="meta-content"><?php _e('Landing Page Content'); ?></label></th>
    <td>
        <div id="catContent">
            <style type="text/css">.form-field input {width: auto!important;}</style>
            <?php wp_editor($cat_meta['content'], 'cat_landing', array(
                    'textarea_name' =>  'cat_meta[content]',
                    'textarea_rows' =>  15,
            )); ?>
        </div>
        <span class="description"><?php _e('Landing Page Content, Edit This Like You Would A Page.'); ?></span>
    </td> 
</tr>
<?php
}
add_action('category_edit_form_fields','extra_category_fields');  

/** Save Category Meta **/
function save_extra_category_fileds( $term_id ) {
    global $wpdb;
    if ( isset( $_POST['cat_meta'] ) ) {
        $t_id = $term_id;
        $cat_meta = get_option( "category_$t_id");
        $cat_keys = array_keys($_POST['cat_meta']);
            foreach ($cat_keys as $key){
            if (isset($_POST['cat_meta'][$key])){
                $cat_meta[$key] = $_POST['cat_meta'][$key];
            }
        }
        update_option( "category_$t_id", $cat_meta );
    }
}
add_action ( 'edited_category', 'save_extra_category_fileds');

With these you can actually do more, such as adding an ordering field or whatever your heart desires.

In the action call you can change:

add_action('category_edit_form_fields','extra_category_fields'); to your specific

taxonomy by changing category to your taxonomy name as so:

add_action('YOUR-TAX-HERE_edit_form_fields','extra_category_fields');
add_action ( 'edited_YOUR-TAX-HERE', 'save_extra_category_fileds');

Finally to get your meta content you can use this:

$category_id = get_cat_ID();
if($category_id != 0){
    $cat_meta = get_option( "category_$category_id");
    echo apply_filters('the_content', $cat_meta['content']);
}
Source Link
Howdy_McGee
  • 20.8k
  • 24
  • 91
  • 175

Here's raw code for the DIY people.

/** Add New Field To Category **/
function extra_category_fields( $tag ) {
    $t_id = $tag->term_id;
    $cat_meta = get_option( "category_$t_id" );
?>
<tr class="form-field">
    <th scope="row" valign="top"><label for="meta-content"><?php _e('Landing Page Content'); ?></label></th>
    <td>
        <div id="catContent">
            <style type="text/css">.form-field input {width: auto!important;}</style>
            <?php wp_editor($cat_meta['content'], 'cat_landing', array(
                    'textarea_name' =>  'cat_meta[content]',
                    'textarea_rows' =>  15,
            )); ?>
        </div>
        <span class="description"><?php _e('Landing Page Content, Edit This Like You Would A Page.'); ?></span>
    </td> 
</tr>
<?php
}
add_action('category_edit_form_fields','extra_category_fields');  

/** Save Category Meta **/
function save_extra_category_fileds( $term_id ) {
    global $wpdb;
    if ( isset( $_POST['cat_meta'] ) ) {
        $t_id = $term_id;
        $cat_meta = get_option( "category_$t_id");
        $cat_keys = array_keys($_POST['cat_meta']);
            foreach ($cat_keys as $key){
            if (isset($_POST['cat_meta'][$key])){
                $cat_meta[$key] = $_POST['cat_meta'][$key];
            }
        }
        update_option( "category_$t_id", $cat_meta );
    }
}
add_action ( 'edited_category', 'save_extra_category_fileds');

With these you can actually do more, such as adding an ordering field or whatever your heart desires.

In the action call you can change:

add_action('category_edit_form_fields','extra_category_fields'); to your specific

taxonomy by changing category to your taxonomy name as so:

add_action('YOUR-TAX-HERE_edit_form_fields','extra_category_fields');
add_action ( 'edited_YOUR-TAX-HERE', 'save_extra_category_fileds');

Finally to get your meta content you can use this:

$category_id = get_cat_ID();
if($category_id != 0){
    $cat_meta = get_option( "category_$category_id");
    echo apply_filters('the_content', $cat_meta['content']);
}