The edit_link_category_form_pre WordPress PHP action fires before the Edit Link Category form and allows you to modify the form or perform other tasks.
Usage
add_action('edit_link_category_form_pre', 'your_custom_function');
function your_custom_function($tag) {
// your custom code here
}
Parameters
$tag(WP_Term) – Current link category term object.
More information
See WordPress Developer Resources: edit_link_category_form_pre
Examples
Display a custom message above the Edit Link Category form
Display a custom message above the Edit Link Category form.
add_action('edit_link_category_form_pre', 'display_custom_message');
function display_custom_message($tag) {
echo '<p><strong>Note:</strong> Please provide a meaningful description for the link category.</p>';
}
Change the title attribute of the Edit Link Category form
Modify the title attribute of the Edit Link Category form.
add_action('edit_link_category_form_pre', 'change_form_title_attribute');
function change_form_title_attribute($tag) {
echo '<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#edittag");
if (form) {
form.setAttribute("title", "Custom Title");
}
});
</script>';
}
Add custom CSS styles to the Edit Link Category form
Add custom CSS styles to the Edit Link Category form.
add_action('edit_link_category_form_pre', 'add_custom_css');
function add_custom_css($tag) {
echo '<style>
.form-wrap {
background-color: #f0f0f0;
border-radius: 8px;
}
</style>';
}
Hide the Description field in the Edit Link Category form
Hide the Description field in the Edit Link Category form.
add_action('edit_link_category_form_pre', 'hide_description_field');
function hide_description_field($tag) {
echo '<script>
document.addEventListener("DOMContentLoaded", function() {
const descriptionField = document.querySelector(".term-description-wrap");
if (descriptionField) {
descriptionField.style.display = "none";
}
});
</script>';
}
Autofill the Slug field in the Edit Link Category form
Automatically fill the Slug field in the Edit Link Category form with a custom value.
add_action('edit_link_category_form_pre', 'autofill_slug_field');
function autofill_slug_field($tag) {
echo '<script>
document.addEventListener("DOMContentLoaded", function() {
const slugField = document.querySelector("#slug");
if (slugField) {
slugField.value = "custom-slug-" + Math.floor(Math.random() * 1000);
}
});
</script>';
}