i want to disable, hide or remove delete buttons from category page
I tried editing functions.php with no luck:
add_action('admin_head', 'hide_category_buttons');
function hide_category_buttons() {
echo '<style>
.taxonomy-category tr:hover .row-actions {
visibility: hidden;
}
</style>';
}
i want to disable, hide or remove delete buttons from category page
I tried editing functions.php with no luck:
add_action('admin_head', 'hide_category_buttons');
function hide_category_buttons() {
echo '<style>
.taxonomy-category tr:hover .row-actions {
visibility: hidden;
}
</style>';
}
Wordpress has a filter for action links.
apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
For product_cat taxonomy:
add_filter('product_cat_row_actions', function($actions, $term) {
unset($actions['delete']);
return $actions;
});
https://developer.wordpress.org/reference/hooks/taxonomy_row_actions/
There is some modification in your code, insted of this class .taxonomy-category tr:hover .row-actions
apply css on this class .taxonomy-category .row-actions span.delete
, it willl work.
Here is whole code.
add_action('admin_head', 'hide_category_buttons');
function hide_category_buttons() {
echo '<style>
.taxonomy-category .row-actions span.delete {
visibility: hidden;
}
</style>';
}
Probably your CSS selector is wrong. You can filter the admin pages where your function runs and you can use an universal selector.
global $pagenow;
if (( $pagenow == 'edit-tags.php' ) && ($_GET['taxonomy'] == 'product_cat') &&
($_GET['post_type'] == 'product') ) {
add_action('admin_head', 'hide_category_buttons');
}
function hide_category_buttons() {
echo '<style> .row-actions > .delete { display: none; } </style>';
}