0

I want to edit the edit-tags.php, particularly the post_tag page. I want to add some content as shown in the pic below.

enter image description here

I have found the way to detect the page with the get_current_screen function, but I'm clueless what to do next. The only thing I can think of is using Javascript to add the element, but that would be hack-ish.

How do you edit the content in edit-tags.php?

0

You can use the dynamic {$taxonomy}_term_new_form_tag action, where you replace {$taxonomy} with your taxonomy slug.

Example1)

For the post_tag taxonomy:

add_action( 'post_tag_term_new_form_tag', function()
{
    printf( '><div class="form-field">%s</div', esc_html__( 'Some content', 'mydomain' ) );
}, PHP_INT_MAX );

1) Update:

I didn't noticed at first that this is inside the <form> tag, so this is a hack to adjust to that and the PHP_INT_MAX priority is here to run it as late as possible. But I don't like this approach, the {$taxonomy}_add_form_fields is more suitable, but then you would need to move it up via CSS (flex order?) or javascript.

It's also possible to hijack the fourth esc_attr() call, after post_tag_term_new_form_tag is fired up, via the attribute_escape filter, i.e. the one inside the wp_nounce_field() but that sounds too unstable.

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.