How to have “the most used tags” taxonomy always expanded?

How can I have some taxonomies to always have “the most used tags” displayed when a new post is being created.

Thanks.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

There does not appear to be any way to hook into that from inside PHP

http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/meta-boxes.php#L300

So JavaScript will probably best suit as a quick and easy solution.

add_action( 'admin_footer-post-new.php', 'wpse_45149_inject_script' );
function wpse_45149_inject_script() {

    $expand_for = array( 'post_tag' ); // add taxonomy names here

    // build a nice jQuery query
    foreach ( $expand_for as &$tax_name ) $tax_name = '#link-'.$tax_name;
    $expand_for = implode( ',', $expand_for );

    ?>
        <script type="text/javascript">
            jQuery(document).ready(function() {
                jQuery('<?php echo $expand_for; ?>').click();
            })
        </script>
    <?php

}

You should probably wp_enqueue_script this script instead (always set position to “footer”). And also hook to the edit.php pages if necessary. Moreover, $expanded_for should probably be escaped.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x