-1

I just want to know what is the difference between the add_action and add_filter. I just could not get it enough in the documentation of wordpress. Can anyone explain it more broader and simpler. Thank you in advance.

-1

add_action

add_action is what you use to create a trigger “hook” – when something happens, do-something-else.

add_Filter add_filter is used to “hook” data change/replace – where there is [some-code], change it to some-other-expanded-code. add_filter ( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) Hook a function or method to a specific filter action. WordPress offers filter hooks to allow plugins to modify various types of internal data at runtime. A plugin can modify data by binding a callback to a filter hook. When the filter is later applied, each bound callback is run in order of priority, and given the opportunity to modify a value by returning a new value.

  • can add_action use this function? function twentynineteen_nav_menu_social_icons( $item_output, $item, $depth, $args ) { // Change SVG icon inside social links menu if there is supported URL. if ( 'social' === $args->theme_location ) { $svg = twentynineteen_get_social_link_svg( $item->url, 26 ); if ( empty( $svg ) ) { $svg = twentynineteen_get_icon_svg( 'link' ); } $item_output = str_replace( $args->link_after, '</span>' . $svg, $item_output ); } return $item_output; } – Lucifer Levi Sep 26 '19 at 2:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.