This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
get_edit_term_link filter
Filters the edit link for a term.
To use the get_edit_term_link filter, first you have to register it using add_filter. You can write this code into the functions.php of your activated theme or in a custom WordPress Plugin.
At WePlugins, we always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.
In the below live example, we have defined a function weplugins_modify_get_edit_term_link_defaults which takes 4 parameters and we registered it using add_filter. The first parameter get_edit_term_link is the name of the hook, the second parameter weplugins_modify_get_edit_term_link_defaults is the name of the function which needs to be called, the third parameter is the priority of calling the hook if the same hook is used multiple times, and the last parameter is the number of arguments (if any) to be passed in the registered function.
Sometimes, you have to remove a registered hook, so you can use remove_filter to remove the get_edit_term_link filter.
Parameters
Below are the 4 parameters required to use this hook:
- $location: (string) The edit link.
- $term_id: (int) Term ID.
- $taxonomy: (string) Taxonomy name.
- $object_type: (string) The object type.
Live Example
apply_filters( 'get_edit_term_link', string $location, int $term_id, string $taxonomy, string $object_type )
Below is an example of how you can use this hook.
Example 1: Modifying the Edit Term Link
This example demonstrates how to modify the edit term link according to your website requirements.
function weplugins_modify_get_edit_term_link_defaults($location, $term_id, $taxonomy, $object_type) { // Update the $location variable according to your website requirements and return this variable. You can modify the $location variable conditionally too if you want. return $location; } // Add the filter add_filter( "get_edit_term_link", "weplugins_modify_get_edit_term_link_defaults", 10, 4 );
Example 2: Removing the Hook Callback
To remove a hook callback, use the example below.
remove_filter( "get_edit_term_link", "weplugins_modify_get_edit_term_link_defaults", 10, 4 );
Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
Example 3: Conditional Modification of Edit Link
In this example, we modify the edit term link conditionally based on the term ID.
function weplugins_modify_get_edit_term_link_conditionally($location, $term_id, $taxonomy, $object_type) { if ($term_id == 123) { // Update the $location specifically for term ID 123 $location = 'https://example.com/custom-edit-link'; } return $location; } // Add the filter add_filter( "get_edit_term_link", "weplugins_modify_get_edit_term_link_conditionally", 10, 4 );
If you’re having any trouble using this hook, please contact our WordPress Development Team and we’d be happy to assist you.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.