2

I'm currently having a little trouble with removing the Archive Headline and Archive Intro Text fields on the category and tag archive screen in WP Admin.

Image of the Category Archive Settings - Archive Headline and Archive Intro Text

On the category and tag archive pages, there is the standard title and description fields which is what the client will use in place of the archive headline and intro text. In order to eliminate confusion, I would like to remove the Archive Headline and Archive Intro Text fields from WP Admin.

In the Genesis framework core files, I found this bit hanging around in cpt-archive-settings.php:

public function archive_box() {
    ?>
    <p><?php printf( __( 'View the <a href="%s">%s archive</a>.', 'genesis' ), get_post_type_archive_link( $this->post_type->name ), $this->post_type->name ); ?></p>

    <table class="form-table">
    <tbody>

        <tr valign="top">
            <th scope="row"><label for="<?php $this->field_id( 'headline' ); ?>"><b><?php _e( 'Archive Headline', 'genesis' ); ?></b></label></th>
            <td>
                <p><input class="large-text" type="text" name="<?php $this->field_name( 'headline' ); ?>" id="<?php $this->field_id( 'headline' ); ?>" value="<?php echo esc_attr( $this->get_field_value( 'headline' ) ); ?>" /></p>
                <p class="description"><?php _e( 'Leave empty if you do not want to display a headline.', 'genesis' ); ?></p>
            </td>
        </tr>

        <tr valign="top">
            <th scope="row"><label for="<?php $this->field_id( 'intro_text' ); ?>"><b><?php _e( 'Archive Intro Text', 'genesis' ); ?></b></label></th>
            <td>
                <?php wp_editor( $this->get_field_value( 'intro_text' ), $this->settings_field . "-intro-text", array( 'textarea_name' => $this->get_field_name( 'intro_text' ) ) ); ?>
                <p class="description"><?php _e( 'Leave empty if you do not want to display any intro text.', 'genesis' ); ?></p>
            </td>
        </tr>

    </tbody>
    </table>

    <?php
}

I've tried the following code in my functions.php file to try to remove the Archive Headline and Archive Intro Text fields. I haven't come up with a solution on how to remove it on category and tag archive edit screens yet, but figured I would begin with the basic function first.

Here is what I got after consulting the WordPress Codex for remove_action as well as remove_meta_box:

add_action( 'admin_menu', 'remove_archive_intro_headline' );
function remove_archive_intro_headline(){
    remove_meta_box( 'archive_box', 'admin_menu', 'normal' );
}

Unfortunately, it did not work. Is there another method that will allow me to remove the Archive Headline and Archive Intro Text fields from WP admin on category and tag archive edit screens? Any help would be much appreciated! Thank you!

  • 1
    remove_meta_box applies only to meta boxes on the "post" edit page. There is no official similar construct for terms and each plugin/theme adds there on in their own way. What you need to do is to look at the exact html in the term edit pages and use it to find where the code that adds it is, and then trace back which hook triggers it, and remoove that hook – Mark Kaplun Sep 19 '16 at 18:08
2

It's not because of the archive_box in cpt-archive-settings.php but because of genesis_taxonomy_archive_options in genesis/lib/admin/term-meta.php.

You can remove it using if you place the following in child theme:

remove_action( 'admin_init', 'genesis_add_taxonomy_archive_options' );

Update:

Those settings are appearing because of the action genesis_add_taxonomy_archive_options attached to admin_init hook.

add_action( 'admin_init', 'genesis_add_taxonomy_archive_options' );

Which again is like this

function genesis_add_taxonomy_archive_options() {

  foreach ( get_taxonomies( array( 'public' => true ) ) as $tax_name ) {
        add_action( $tax_name . '_edit_form', 'genesis_taxonomy_archive_options', 10, 2 );
    }

}

So basically it is hooking to {$taxonomy}_edit_form.

Another Way

The following works even if it is used in plugin/theme.

add_action( 'admin_init', 'wpse_add_taxonomy_archive_options', 11 );

function wpse_add_taxonomy_archive_options() {

    foreach ( get_taxonomies( array( 'public' => true ) ) as $tax_name ) {
        remove_action( $tax_name . '_edit_form', 'genesis_taxonomy_archive_options', 10, 2 );
    }

}

Thanks to @Mark.

  • edit suggestion ... which hook to use to call this code – Mark Kaplun Sep 19 '16 at 18:09
  • @MarkKaplun Updated the answer, please feel free to edit the answer if you may, I'm happy to accept it – bravokeyl Sep 19 '16 at 18:19
  • it works directly because where you have put it is probably after the action was added by genesis. If you would have put it in a plugin for example it would not have any affect as it would have executed before the theme has added the hook. I will add a small edit – Mark Kaplun Sep 19 '16 at 18:24
  • Aha! great! I get it what you were asking now..please make an edit – bravokeyl Sep 19 '16 at 18:25
  • I just added one more way. – bravokeyl Sep 19 '16 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.