{"id":15674,"date":"2026-06-09T08:01:43","date_gmt":"2026-06-09T08:01:43","guid":{"rendered":"https:\/\/www.24x7wpsupport.com\/blog\/?p=15674"},"modified":"2026-06-09T08:13:25","modified_gmt":"2026-06-09T08:13:25","slug":"add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide","status":"publish","type":"post","link":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/","title":{"rendered":"add_action vs do_action vs add_filter in WordPress: Full Guide"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><span style=\"font-weight: 400;\">WordPress hooks help developers change website behavior safely. They allow custom code to run without editing WordPress core files. This makes the website easier to update and maintain.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Hooks are used in themes, plugins, and custom code snippets. They help add features, change layouts, load files, and connect functions. This is why every WordPress developer should understand hooks clearly.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There are two main hook types in WordPress. These are actions and filters. Actions run custom tasks at specific points. Filters change data before WordPress shows or saves it.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Many beginners get confused between add_action, do_action, and add_filter. These functions sound similar, but they work differently. This guide explains them in a simple and practical way.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Understanding these functions helps you write cleaner WordPress code. It also reduces errors when customizing websites.<\/span><\/p>\n<h2>What Is add_action in WordPress?<\/h2>\n<p><span style=\"font-weight: 400;\">add_action() is a WordPress function used to attach custom code. It connects your function to a specific WordPress action hook. When that hook runs, WordPress also runs your custom function.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In simple words, add_action in WordPress tells the website when to run your code. For example, you can run code when a page loads. You can also add scripts, show messages, or send emails.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, what is add_action in WordPress? It is a way to register your function with an action hook. It does not create the hook itself. It only connects your function to an existing hook.<\/span><\/p>\n<p><strong>Developers commonly use add_action() for many tasks, such as:<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Loading CSS and JavaScript files.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Adding code inside the header or footer.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Running code after a post is published.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Sending emails after a form submission.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Adding custom dashboard notices.<\/span><\/li>\n<\/ul>\n<p><strong>The basic syntax is simple:<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">add_action( &#8216;hook_name&#8217;, &#8216;callback_function&#8217; );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here, hook_name is the action hook name. The callback_function is your custom function. WordPress runs that function when the selected hook is triggered.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This makes add_action() very useful for safe WordPress customization.<\/span><\/p>\n<h3>WordPress add_action Example for Beginners<\/h3>\n<p><span style=\"font-weight: 400;\">Understanding a practical example makes WordPress hooks easier to learn. A simple example helps beginners understand how add_action() works inside a website.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This WordPress add_action example shows how to add custom content inside the website footer. Many developers use this method for tracking scripts, messages, or notices.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is a simple code example:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">function custom_footer_message() {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">echo &#8216;&lt;p&gt;Welcome to our WordPress website.&lt;\/p&gt;&#8217;;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">add_action( &#8216;wp_footer&#8217;, &#8216;custom_footer_message&#8217; );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This code has two important parts. The first part creates a custom function. The second part connects that function using add_action().<\/span><\/p>\n<p><strong>Let\u2019s understand each part clearly:<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">custom_footer_message() is the custom callback function.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">wp_footer is the action hook name.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">add_action() connects the function to that hook.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">WordPress runs the function before the closing body tag.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">When the footer section loads, WordPress triggers the wp_footer hook. Then it automatically runs the connected function.<\/span><\/p>\n<p><strong>This method is useful for many website customization tasks, such as:<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Adding custom footer text.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Loading tracking scripts safely.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Showing promotional messages.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Adding popup or analytics code.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Running custom plugin functions.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Developers also use priority values with add_action(). Priority controls the order of execution when multiple functions use the same hook.<\/span><\/p>\n<p><strong>Example with priority:<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">add_action( &#8216;wp_footer&#8217;, &#8216;custom_footer_message&#8217;, 20 );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here, 20 is the priority number. Lower numbers run earlier. Higher numbers run later.<\/span><\/p>\n<h4>What Is do_action in WordPress?<\/h4>\n<p><span style=\"font-weight: 400;\">do_action() is another important WordPress hook function. It works differently from add_action().<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The do_action() function triggers or fires an action hook. It tells WordPress to run all connected functions immediately.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In simple words, do_action() creates the execution point. Then add_action() connects functions to that point.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is a simple example:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">do_action( &#8216;custom_hook_name&#8217; );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When WordPress reaches this line, it runs every function attached to custom_hook_name.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Theme and plugin developers use do_action() to create flexible customization areas. Other developers can then attach custom functions without changing original files.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This makes WordPress development cleaner, safer, and easier to maintain.<\/span><\/p>\n<h4>add_action vs do_action: Main Difference<\/h4>\n<p><span style=\"font-weight: 400;\">The topic add_action vs do_action often confuses WordPress beginners. Both functions work with action hooks, but their roles are different. One connects code to a hook. The other runs that hook at a specific place.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The simplest difference between add_action and do_action is this: add_action() registers your custom function, while do_action() fires the hook. So, add_action() waits for an event. do_action() creates or triggers that event.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Think of do_action() as a switch. It tells WordPress, \u201cRun all functions attached here.\u201d Think of add_action() as the wire connected to that switch. It tells WordPress which function should run when the switch turns on.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is a simple example:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">function show_custom_notice() {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">echo &#8216;&lt;p&gt;This is a custom notice.&lt;\/p&gt;&#8217;;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">add_action( &#8216;my_custom_hook&#8217;, &#8216;show_custom_notice&#8217; );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">do_action( &#8216;my_custom_hook&#8217; );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this code, add_action() attaches show_custom_notice() to my_custom_hook. Then do_action() triggers my_custom_hook. After that, WordPress runs the connected function.<\/span><\/p>\n<p><strong>You can understand both functions with this:<\/strong><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 <\/span><strong>Main role:<\/strong><span style=\"font-weight: 400;\"> add_action connects a function to a hook. do_action runs the hook.<\/span><\/li>\n<li><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 <\/span><strong>Purpose:<\/strong><span style=\"font-weight: 400;\"> add_action registers custom code. do_action creates an execution point.<\/span><\/li>\n<li><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 <\/span><strong>Used for:<\/strong><span style=\"font-weight: 400;\"> add_action adds custom behavior. do_action triggers connected behavior.<\/span><\/li>\n<li><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 <\/span><strong>Common use:<\/strong><span style=\"font-weight: 400;\"> add_action is used for theme or plugin customization. do_action is used for custom hook locations.<\/span><\/li>\n<li><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 <\/span><strong>Works like:<\/strong><span style=\"font-weight: 400;\"> add_action works like a listener. do_action works like a trigger.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Use add_action() when WordPress already provides the hook. For example, use it with wp_footer, wp_head, or init. These hooks already exist in WordPress.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use do_action() when you want to create your own action point. This is useful in custom themes and plugins. It helps other developers extend your code safely.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, add_action() and do_action() are not replacements. They work together in the WordPress hook system. One attaches the function, and the other starts the action.<\/span><\/p>\n<h4>What Is add_filter in WordPress?<\/h4>\n<p><span style=\"font-weight: 400;\">add_filter() is a WordPress function used to change data. It connects a custom function to a filter hook. WordPress then passes data through that function before using it.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Filters are different from actions. Actions run a task at a specific point. Filters receive data, change it, and return it again.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Developers use add_filter() when they want to edit output safely. For example, they can change a post title. They can also update excerpt text or modify content before display.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Common uses of add_filter() include:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Changing post titles before display.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Editing excerpt length or ending text.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Modifying content before it appears.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Changing WooCommerce product text.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Updating custom plugin output.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">A filter function must return the final value. This is very important. If it does not return data, the output may break.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here is a simple example:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">function change_post_title( $title ) {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">return $title . &#8216; &#8211; Updated&#8217;;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">add_filter( &#8216;the_title&#8217;, &#8216;change_post_title&#8217; );<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this example, WordPress sends the title into the function. The function changes it and returns the updated title.<\/span><\/p>\n<h4>add_action vs add_filter: Key Difference<\/h4>\n<p><span style=\"font-weight: 400;\">The topic add_action vs add_filter is important for WordPress beginners. Both functions connect custom functions to hooks. However, they do different jobs.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The main difference between add_action and add_filter is simple. add_action() performs a task. add_filter() changes a value.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use add_action() when you want WordPress to run code. For example, you can load scripts, send emails, or show notices. It usually does not need to return any value.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use add_filter() when you want to change existing data. For example, you can edit titles, content, excerpts, prices, or labels. A filter should always return the changed value.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can understand the difference this way:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><strong>Main use:<\/strong><span style=\"font-weight: 400;\"> add_action() performs an action. add_filter() modifies data.<\/span><\/li>\n<li style=\"font-weight: 400;\"><strong>Return value:<\/strong><span style=\"font-weight: 400;\"> add_action() usually needs no return. add_filter() must return data.<\/span><\/li>\n<li style=\"font-weight: 400;\"><strong>Hook type:<\/strong><span style=\"font-weight: 400;\"> add_action() works with action hooks. add_filter() works with filter hooks.<\/span><\/li>\n<li style=\"font-weight: 400;\"><strong>Best example:<\/strong><span style=\"font-weight: 400;\"> add_action() can load CSS files. add_filter() can change a post title.<\/span><\/li>\n<li style=\"font-weight: 400;\"><strong>Common mistake:<\/strong><span style=\"font-weight: 400;\"> Beginners use filters without returning values.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Both functions help customize WordPress safely. They also reduce the need to edit core files. When used correctly, they make websites easier to manage.<\/span><\/p>\n<h4>When Should You Use add_action, do_action, or add_filter?<\/h4>\n<p><span style=\"font-weight: 400;\">Use each WordPress hook function for its correct purpose. This keeps your code clean, safe, and easier to update.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use add_action() when you want to run custom code. It is helpful for loading files, sending emails, adding notices, or running plugin tasks.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use do_action() when you want to create a custom action point. This is useful inside custom themes, plugins, or reusable code blocks.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use add_filter() when you want to change existing data. It works well for titles, content, excerpts, labels, and output text.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can follow this simple rule:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Use add_action() to perform a task.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Use do_action() to fire a custom hook.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Use add_filter() to change returned data.<\/span><\/li>\n<\/ul>\n<h4>Common Mistakes Beginners Should Avoid<\/h4>\n<p><span style=\"font-weight: 400;\">Beginners often mix these functions because names look similar. However, each one has a different job inside WordPress.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Avoid using do_action() when you need add_action(). do_action() only fires a hook. It does not attach your function.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Do not use add_filter() without returning a value. Filters must return the final data. Otherwise, WordPress may show empty or broken output.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Also, avoid editing WordPress core files directly. Use hooks instead for safer customization.<\/span><\/p>\n<p><strong>Common mistakes include:<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Using the wrong hook name.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Forgetting the return value in filters.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Adding code in unsafe theme files.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Ignoring priority when many functions run.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Testing code directly on a live website.<\/span><\/li>\n<\/ul>\n<h3>Conclusion<\/h3>\n<p><span style=\"font-weight: 400;\">Understanding these functions makes WordPress customization much easier. add_action() connects code to action hooks. do_action() fires custom action hooks. add_filter() changes data before WordPress uses it.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When you understand their roles, you can write safer code. You can also customize themes and plugins more professionally.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For expert WordPress help, custom code support, or hook-related issues, <\/span><a style=\"color: #ffba00; text-decoration: underline;\" href=\"https:\/\/www.24x7wpsupport.com\">24&#215;7 WP Support<\/a> can guide you with reliable technical support.<span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction WordPress hooks help developers change website behavior safely. They allow custom code to run without editing WordPress core files. &#8230;<\/p>\n","protected":false},"author":1,"featured_media":15678,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1096],"tags":[2205,2207,2206,1595],"class_list":["post-15674","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-add_action-wordpress","tag-add_filter-wordpress","tag-do_action-wordpress","tag-wordpress-hooks"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>add_action vs do_action vs add_filter in WordPress<\/title>\n<meta name=\"description\" content=\"Learn the difference between add_action, do_action, and add_filter in WordPress with simple examples and clear hook explanations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"add_action vs do_action vs add_filter in WordPress\" \/>\n<meta property=\"og:description\" content=\"Learn the difference between add_action, do_action, and add_filter in WordPress with simple examples and clear hook explanations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7WPSupport Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/24x7wpsupport\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-09T08:01:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-09T08:13:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2026\/06\/add-action-vs-do-action-vs-add-filter.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"460\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Brian\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wpsupport24x7\" \/>\n<meta name=\"twitter:site\" content=\"@wpsupport24x7\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brian\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/\"},\"author\":{\"name\":\"Brian\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#\\\/schema\\\/person\\\/40ee989d8d57096afc53a526d6e612b0\"},\"headline\":\"add_action vs do_action vs add_filter in WordPress: Full Guide\",\"datePublished\":\"2026-06-09T08:01:43+00:00\",\"dateModified\":\"2026-06-09T08:13:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/\"},\"wordCount\":1719,\"publisher\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/add-action-vs-do-action-vs-add-filter.png\",\"keywords\":[\"add_action WordPress\",\"add_filter WordPress\",\"do_action WordPress\",\"WordPress hooks\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/\",\"url\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/\",\"name\":\"add_action vs do_action vs add_filter in WordPress\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/add-action-vs-do-action-vs-add-filter.png\",\"datePublished\":\"2026-06-09T08:01:43+00:00\",\"dateModified\":\"2026-06-09T08:13:25+00:00\",\"description\":\"Learn the difference between add_action, do_action, and add_filter in WordPress with simple examples and clear hook explanations.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/add-action-vs-do-action-vs-add-filter.png\",\"contentUrl\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/add-action-vs-do-action-vs-add-filter.png\",\"width\":825,\"height\":460,\"caption\":\"add action vs do action vs add filter\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"add_action vs do_action vs add_filter in WordPress: Full Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/\",\"name\":\"24x7WPSupport Blog\",\"description\":\"WordPress Theme Update | WordPress Blog\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#organization\",\"name\":\"24x7 WP Support\",\"url\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/wpsupportlatestlogo.png\",\"contentUrl\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/wpsupportlatestlogo.png\",\"width\":269,\"height\":64,\"caption\":\"24x7 WP Support\"},\"image\":{\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/24x7wpsupport\",\"https:\\\/\\\/x.com\\\/wpsupport24x7\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.24x7wpsupport.com\\\/blog\\\/#\\\/schema\\\/person\\\/40ee989d8d57096afc53a526d6e612b0\",\"name\":\"Brian\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5a5a62eb3263db905a008db8d80b6777dd5792da217d72772ec4c23dc58ec9d6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5a5a62eb3263db905a008db8d80b6777dd5792da217d72772ec4c23dc58ec9d6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5a5a62eb3263db905a008db8d80b6777dd5792da217d72772ec4c23dc58ec9d6?s=96&d=mm&r=g\",\"caption\":\"Brian\"},\"description\":\"Brian is a WordPress support specialist and content contributor at 24x7 WP Support. He writes practical, easy-to-follow guides on WordPress troubleshooting, WooCommerce issues, plugin and theme errors, website security, migrations, performance optimization, and integrations. With a focus on solving real website problems, Brian helps business owners, bloggers, and online store managers keep their WordPress sites running smoothly.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"add_action vs do_action vs add_filter in WordPress","description":"Learn the difference between add_action, do_action, and add_filter in WordPress with simple examples and clear hook explanations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/","og_locale":"en_GB","og_type":"article","og_title":"add_action vs do_action vs add_filter in WordPress","og_description":"Learn the difference between add_action, do_action, and add_filter in WordPress with simple examples and clear hook explanations.","og_url":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/","og_site_name":"24x7WPSupport Blog","article_publisher":"https:\/\/www.facebook.com\/24x7wpsupport","article_published_time":"2026-06-09T08:01:43+00:00","article_modified_time":"2026-06-09T08:13:25+00:00","og_image":[{"width":825,"height":460,"url":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2026\/06\/add-action-vs-do-action-vs-add-filter.png","type":"image\/png"}],"author":"Brian","twitter_card":"summary_large_image","twitter_creator":"@wpsupport24x7","twitter_site":"@wpsupport24x7","twitter_misc":{"Written by":"Brian","Estimated reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#article","isPartOf":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/"},"author":{"name":"Brian","@id":"https:\/\/www.24x7wpsupport.com\/blog\/#\/schema\/person\/40ee989d8d57096afc53a526d6e612b0"},"headline":"add_action vs do_action vs add_filter in WordPress: Full Guide","datePublished":"2026-06-09T08:01:43+00:00","dateModified":"2026-06-09T08:13:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/"},"wordCount":1719,"publisher":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2026\/06\/add-action-vs-do-action-vs-add-filter.png","keywords":["add_action WordPress","add_filter WordPress","do_action WordPress","WordPress hooks"],"articleSection":["WordPress"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/","url":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/","name":"add_action vs do_action vs add_filter in WordPress","isPartOf":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2026\/06\/add-action-vs-do-action-vs-add-filter.png","datePublished":"2026-06-09T08:01:43+00:00","dateModified":"2026-06-09T08:13:25+00:00","description":"Learn the difference between add_action, do_action, and add_filter in WordPress with simple examples and clear hook explanations.","breadcrumb":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#primaryimage","url":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2026\/06\/add-action-vs-do-action-vs-add-filter.png","contentUrl":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2026\/06\/add-action-vs-do-action-vs-add-filter.png","width":825,"height":460,"caption":"add action vs do action vs add filter"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7wpsupport.com\/blog\/add_action-vs-do_action-vs-add_filter-in-wordpress-full-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7wpsupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"add_action vs do_action vs add_filter in WordPress: Full Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7wpsupport.com\/blog\/#website","url":"https:\/\/www.24x7wpsupport.com\/blog\/","name":"24x7WPSupport Blog","description":"WordPress Theme Update | WordPress Blog","publisher":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7wpsupport.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.24x7wpsupport.com\/blog\/#organization","name":"24x7 WP Support","url":"https:\/\/www.24x7wpsupport.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.24x7wpsupport.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2018\/11\/wpsupportlatestlogo.png","contentUrl":"https:\/\/www.24x7wpsupport.com\/blog\/wp-content\/uploads\/2018\/11\/wpsupportlatestlogo.png","width":269,"height":64,"caption":"24x7 WP Support"},"image":{"@id":"https:\/\/www.24x7wpsupport.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/24x7wpsupport","https:\/\/x.com\/wpsupport24x7"]},{"@type":"Person","@id":"https:\/\/www.24x7wpsupport.com\/blog\/#\/schema\/person\/40ee989d8d57096afc53a526d6e612b0","name":"Brian","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/5a5a62eb3263db905a008db8d80b6777dd5792da217d72772ec4c23dc58ec9d6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5a5a62eb3263db905a008db8d80b6777dd5792da217d72772ec4c23dc58ec9d6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5a5a62eb3263db905a008db8d80b6777dd5792da217d72772ec4c23dc58ec9d6?s=96&d=mm&r=g","caption":"Brian"},"description":"Brian is a WordPress support specialist and content contributor at 24x7 WP Support. He writes practical, easy-to-follow guides on WordPress troubleshooting, WooCommerce issues, plugin and theme errors, website security, migrations, performance optimization, and integrations. With a focus on solving real website problems, Brian helps business owners, bloggers, and online store managers keep their WordPress sites running smoothly."}]}},"_links":{"self":[{"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/posts\/15674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/comments?post=15674"}],"version-history":[{"count":3,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/posts\/15674\/revisions"}],"predecessor-version":[{"id":15676,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/posts\/15674\/revisions\/15676"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/media\/15678"}],"wp:attachment":[{"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/media?parent=15674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/categories?post=15674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7wpsupport.com\/blog\/wp-json\/wp\/v2\/tags?post=15674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}