0

My site uses blog categories and several custom taxonomies.

I need a way to add 1-2 sentences of inline help above the checklist of terms in the admin. The custom taxonomies are associated with several post types (post, page, and several CPTs) but the help text does not need to change based on post type.

Examples of help text:

Categories: Categories organize the blog archives and appear in the side navigation. You may select one or more category in which to archive your blog article.

Practice Areas: Practice areas you check off will appear in a list of legal specialities on the attorney's bio page.

Here is a rough idea of what I'd like to do:

example of desired inline help text

Are there any hooks I can use to inject this help text, any existing plugins that do this, or is my best route something like a jQuery function that outputs HTML, since the category and custom taxonomy checklists are conveniently given custom IDs that I can target?

0

This is an adaption of an answer by /user/gmazzap so there may be better way to go about it. Either way, I got it to work.

Pretty much you would filter the checklist arguments and pass in a new Walker Class which you can then define what happens at the start of the list start_lvl(). At that point you should be able to pass any HTML you need to. You should test this in a few cases just to make sure it works in the scenario(s) you need it to. Also note that there's a taxonomy limit on the conditional in taxonomy_checklist_desc() so that it only shows in category but you can remove this to apply to all taxonomies or add more taxonomies if need be.

/**
 * Add Description To Taxonomy Term Checklist Metabox
 * @param array $args
 * @return array $args
 */
function taxonomy_checklist_desc( $args ) {
  if (
    ! empty( $args['taxonomy'] )
    && ( $args['taxonomy'] === 'category' ) // only for 'category' taxonomy
    && ( ! isset( $args['walker'] ) || ! $args['walker'] instanceof Walker )
  ) {
    $args['walker'] = get_Walker_Tax_Meta_Desc();
  }
  return $args;
}

function get_Walker_Tax_Meta_Desc() {

    class Walker_Tax_Meta_Desc extends Walker_Category_Checklist {

        function start_lvl( &$output, $depth = 0, $args = array() ) {
          ?>
            <a href="http://i.imgur.com/eu6xBup.jpg"><em>This is where I'd put my description... IF I HAD ONE!</em></a>
          <?php
            parent::start_lvl( $output, $depth = 0, $args );
        }

    }
    return new Walker_Tax_Meta_Desc;
}
add_filter( 'wp_terms_checklist_args', 'taxonomy_checklist_desc' );

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.