{"id":24866,"date":"2015-10-06T21:01:38","date_gmt":"2015-10-06T13:01:38","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=24866"},"modified":"2024-07-30T00:19:45","modified_gmt":"2024-07-29T16:19:45","slug":"wp-action-hooks-theme-customization","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/","title":{"rendered":"Mastering WordPress Action Hooks for Theme Customization"},"content":{"rendered":"<p>WordPress <a href=\"https:\/\/www.hongkiat.com\/blog\/wordpress-child-themes-dev\/\">child themes<\/a> provide an easy way to customize the appearance of a theme. If the theme\u2019s options don\u2019t give you enough design choices, you can simply add a new rule to the child theme\u2019s default stylesheet file, style.css. But what if you also want to <strong>modify the theme\u2019s functionality<\/strong>? This is where WordPress action hooks come into play.<\/p>\n<p>WordPress\u2019s popularity is partly due to its high customizability. The WordPress Core is packed with various hooks that let developers modify or enhance default functionality. Additionally, you can include <strong>custom hooks<\/strong> in your themes and plugins to <strong>help other developers easily adjust your code to their needs<\/strong>.<\/p>\n<h2>Understanding WordPress Hooks<\/h2>\n<p>WordPress hooks are similar to real-life hooks: you can catch the function you need if you use them correctly.<\/p>\n<p>With hooks, you can <strong>remove a function<\/strong> (e.g., remove the WordPress admin bar for low-level users), <strong>leave it as is<\/strong> and <strong>enhance it<\/strong> with additional functionality (e.g., add more menus or widget areas to a theme), or <strong>override it<\/strong> (e.g., change the behavior of a core function).<\/p>\n<p>There are two types of hooks in WordPress: <em>actions<\/em> and <em>filters<\/em>. In this post, we\u2019ll explore how to <strong>use action hooks for theme customization<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg\" alt=\"Diagram of WordPress Hooks\" width=\"700\" height=\"519\"><\/figure>\n<h2>How WordPress Hooks Work<\/h2>\n<p>In simple terms, <em>actions<\/em> indicate that <strong>something has happened during the WordPress page lifecycle<\/strong>. This could mean that certain parts of the site have been loaded, specific options or settings have been set up, or plugins or widgets have been initialized, among other events.<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Filter_Reference\"><em>Filters<\/em><\/a> differ from <em>actions<\/em> in their purpose. Filters are used to <strong>pass data through<\/strong> and <strong>modify, manage<\/strong>, or <strong>intercept<\/strong> it before it is rendered on the screen or saved to the database.<\/p>\n<p>At every significant point in the WordPress page lifecycle, there is either an <em>action<\/em> or a <em>filter<\/em> hook available where you can <strong>add your custom code to modify the default behavior<\/strong> to suit your needs.<\/p>\n<p>The specific actions and filters that run during a request depend on the type of page requested by the user agent. For example, in a single post request, hooks related to single posts are available, but hooks related to other parts of the site (e.g., the admin area) are not.<\/p>\n<h2>Finding Action Hooks<\/h2>\n<p>The <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\">Action Reference<\/a> in the WordPress Codex provides a detailed overview of the actions running through different requests. The key is to <strong>hook into the right place<\/strong> to accomplish a task effectively. Hooking too early or too late means the action won\u2019t execute correctly.<\/p>\n<p>For instance, if we want to <strong>add our Google Analytics code to a site<\/strong>, we need to <strong>hook our action right before the footer is loaded<\/strong>.<\/p>\n<p>When it comes to theme customization, action hooks can originate from two sources: <strong>WordPress Core<\/strong> and <strong>the theme itself<\/strong>. Some themes have no hooks at all, while others offer a few or many, depending on the theme author\u2019s choice. The default Twenty Fifteen Theme has only one action hook for footer customization, named \u2018twentyfifteen_credits\u2019.<\/p>\n<p>If you prefer browsing source code, finding action hooks is straightforward. Action hooks are added to the code with the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/do_action\/\">do_action()<\/a> WordPress function.<\/p>\n<p>By running a quick search for \u2018do_action\u2019 in an advanced code editor \u2013 like I did in Eclipse below \u2013 you can see a list of spots where you can hook your custom functionality into the core. I searched in the <em>\/wp-includes\/<\/em> folder, but you can also search in the <em>\/wp-admin\/<\/em> folder to find action hooks related to the WordPress dashboard (admin area).<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/action-hooks-in-wp-includes.jpg\" alt=\"List of Action Hooks in WP Includes folder\" width=\"700\" height=\"477\"><\/figure>\n<p>The names of the action hooks are usually quite self-explanatory, and there is <strong>often a helpful comment within the code<\/strong> that provides more context about the action hook\u2019s purpose.<\/p>\n<p>For example, the comment before the \u2018widgets_init\u2019 action hook states that it \u201cfires after all default WordPress widgets have been registered.\u201d By examining the code before this action hook, you can find the initialization of all default WP widgets, confirming the comment\u2019s accuracy. If you want to register your custom widget, this is the right spot.<\/p>\n<p>In many cases, the source code provides more information than the Codex, so it\u2019s beneficial to learn how to navigate it quickly.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/default-widgets-action-hook.jpg\" alt=\"Widgets_init Action Hook in the code\" width=\"700\" height=\"369\"><\/figure>\n<h2>Add Your Own Actions<\/h2>\n<p>To add your own action, you need to <strong>create a custom function<\/strong> and <strong>bind this function to a specific action hook<\/strong> using the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/add_action\">add_action()<\/a> WordPress function. Custom actions added with the add_action() function are typically <strong>triggered on the spot<\/strong> when the core calls the appropriate do_action() function.<\/p>\n<p>Let\u2019s look at a simple example.<\/p>\n<h3>How to Find the Action Hook You Need<\/h3>\n<p>Suppose you want to add your custom favicon to your site. First, you need to find the right action hook to bind your functionality to.<\/p>\n<p>Think about it. If you wanted to add a favicon to a plain HTML page, where would you put it? Naturally, you would place it inside the &lt;head&gt; section of the HTML file with the following markup:<\/p>\n<pre>\r\n&lt;link rel=\"shortcut icon\" href=\"\/https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/your-favicon.ico\" type=\"image\/x-icon\" \/&gt;\r\n<\/pre>\n<p>Therefore, the action hook you need must be <strong>related to the loading of the <code>&lt;head&gt;<\/code> section<\/strong>.<\/p>\n<ol>\n<li>Open the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/\">Action Reference<\/a> and see what it offers. Fortunately, there is only one, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/wp_head\">wp_head<\/a>, which, based on its name, seems related to the loading of the &lt;head&gt; section.<\/li>\n<li>To confirm, let\u2019s <strong>check the documentation in the WordPress Codex<\/strong>. The Codex advises that \u201cyou use this hook by having your function echo output to the browser,\u201d which sounds perfect. But let\u2019s verify it in the source code.<\/li>\n<li>Since this hook is not related to the admin area, we need to search in the <em>\/wp-includes\/<\/em> folder. Searching for \u2018wp-head\u2019 yields many results, as this action is frequently used by WP Core.<\/li>\n<\/ol>\n<p>We need to find where it is defined, so search for <strong>do_action( \u2018wp_head\u2019<\/strong>. Note that we don\u2019t finish the parentheses because we aren\u2019t sure yet if this action has parameters.<\/p>\n<p>Eclipse returns only one result inside the <em>\/wp-includes\/general-template.php<\/em> file. The comment before the action hook definition states that it \u201cprints scripts or data in the head tag on the front end,\u201d confirming that <strong>wp_head<\/strong> is indeed the action hook we need.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/find-wp-head.jpg\" alt=\"Finding wp_head action hook in the code\" width=\"700\" height=\"369\"><\/figure>\n<h3>Checking for Parameters<\/h3>\n<p>When adding your own actions, you need to determine if the hook you want to use takes parameters. You can easily find this out by looking at the do_action() function.<\/p>\n<p>The syntax of the do_action() function is as follows:<\/p>\n<pre>\r\ndo_action( 'name_of_action'[, $parameter1, $parameter2, ...] )\r\n<\/pre>\n<p>Only the name of the action is required; the parameters are optional. If you find arguments in the relevant call of the do_action() function, you need to <strong>include them in the declaration of the custom function you create<\/strong>.<\/p>\n<p>If there are no parameters, your custom function must work without arguments. For example, the do_action() definition of the wp_head action hook has no parameters.<\/p>\n<p>Let\u2019s compare this to an action hook that takes a parameter. The action hook called \u2018wp_register_sidebar_widget\u2019 takes one parameter that you always have to pass to the custom function you bind to the hook.<\/p>\n<p>Here is the difference in the do_action() syntax for the two cases:<\/p>\n<pre>\r\ndo_action( 'wp_head' );\r\n\r\ndo_action( 'wp_register_sidebar_widget', $widget );\r\n<\/pre>\n<p>In the first case, there\u2019s no parameter, so the custom function will use the following syntax:<\/p>\n<pre>\r\nfunction my_function_without_parameters() { ... }\r\n<\/pre>\n<p>In the second case, there is one parameter that you always have to pass as an argument into the declaration of your custom function:<\/p>\n<pre>\r\nfunction my_function_with_parameters( $widget ) { ... }\r\n<\/pre>\n<h3>How to Hook Your Custom Function In<\/h3>\n<p>Now we have everything we need. Let\u2019s create our custom function to display a favicon on our site.<\/p>\n<p>First, create a new function without any arguments, then bind it to the wp_head action hook using the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/add_action\">add_action()<\/a> WordPress function.<\/p>\n<pre>\r\nfunction custom_add_favicon() {\r\n    echo '&lt;link rel=\"shortcut icon\" href=\"\/https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/your-favicon.ico\" type=\"image\/x-icon\" \/&gt;';\r\n}\r\nadd_action( 'wp_head', 'custom_add_favicon');\r\n<\/pre>\n<p>You need to <strong>pass the name<\/strong> of the action hook <strong>to the add_action() function<\/strong> <strong>as an argument first<\/strong>, then you need to <strong>add the name of your custom function<\/strong>.<\/p>\n<p>These are the two required parameters of add_action(). It has two optional parameters too, <strong>priority<\/strong> and <strong>accepted arguments<\/strong>. Let\u2019s see how to use these.<\/p>\n<h3>Define Priorities<\/h3>\n<p>In many cases, more than one action is bound to the same hook. So, <strong>which one will be executed first<\/strong>? This is where we can use the <strong>$priority optional parameter<\/strong> of the add_action() function.<\/p>\n<p>We add the priority as a positive integer, <strong>the default value being 10<\/strong>. If we want an action to be executed early, we give it a lower value; if we want it to be executed later, we give it a higher value.<\/p>\n<p>So if we think that the favicon needs to be there early, we can enhance our previous add_action() call in the following way:<\/p>\n<pre>\r\nadd_action( 'wp_head', 'custom_add_favicon', 5);\r\n<\/pre>\n<p>Note that the priorities always have to be <strong>set relative to the other custom functions<\/strong> that use the same action hook.<\/p>\n<h3>Add the Number of Accepted Arguments<\/h3>\n<p>You need to specify the number of accepted arguments when using an action hook that takes parameters. Let\u2019s revisit the previous example.<\/p>\n<p>The action hook \u2018wp_register_sidebar_widget\u2019 takes one parameter. So, when we bind our custom function to this hook, we must include this as an argument when calling the add_action() function.<\/p>\n<p>Our code in this case will look like this:<\/p>\n<pre>\r\nfunction my_sidebar_widget_function( $widget ) {\r\n    \/\/ Your code\r\n}\r\nadd_action( 'wp_register_sidebar_widget', 'my_sidebar_widget_function', 10, 1);\r\n<\/pre>\n<p>Note that we must <strong>also add the priority<\/strong> (we chose the default 10 here) to ensure WordPress understands what each parameter represents. <strong>If we omitted the priority, WordPress might assume that 1 is the priority<\/strong>, which is incorrect, as it actually indicates the number of accepted arguments.<\/p>\n<h2>Conclusion<\/h2>\n<p>You can experiment with action hooks in theme customization. For instance, you can add custom scripts (JS) and styles (CSS) with the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/wp_enqueue_scripts\">wp_enqueue_scripts<\/a> action hook, or your Google Analytics code with the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Action_Reference\/wp_footer\">wp_footer<\/a> action hook.<\/p>\n<p>Not only can you <strong>add your own actions<\/strong>, but you can also <strong>remove complete functionalities<\/strong> from the WordPress core using the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/remove_action\">remove_action()<\/a> function, which operates similarly to add_action().<\/p>\n<p>If you are a theme author and want to create an extensible theme, consider <strong>adding your own custom action hooks to the appropriate template files<\/strong> using the do_action() function.<\/p>\n<p>When doing so, <strong>carefully consider the parameters that other developers<\/strong> using your theme <strong>will need to pass as arguments<\/strong> when they hook in their custom functionalities.<\/p>\n<p>While designing the locations of your theme\u2019s custom action hooks, remember that it <strong>doesn\u2019t make much sense to include custom theme hooks in the same spots where the WordPress Core already has its own hooks<\/strong>.<\/p>","protected":false},"excerpt":{"rendered":"<p>WordPress child themes provide an easy way to customize the appearance of a theme. If the theme\u2019s options don\u2019t give you enough design choices, you can simply add a new rule to the child theme\u2019s default stylesheet file, style.css. But what if you also want to modify the theme\u2019s functionality? This is where WordPress action&hellip;<\/p>\n","protected":false},"author":146,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[49],"tags":[4663,365,252],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Mastering WordPress Action Hooks for Theme Customization - Hongkiat<\/title>\n<meta name=\"description\" content=\"WordPress child themes provide an easy way to customize the appearance of a theme. If the theme&#039;s options don&#039;t give you enough design choices, you can\" \/>\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.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mastering WordPress Action Hooks for Theme Customization\" \/>\n<meta property=\"og:description\" content=\"WordPress child themes provide an easy way to customize the appearance of a theme. If the theme&#039;s options don&#039;t give you enough design choices, you can\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-06T13:01:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-29T16:19:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg\" \/>\n<meta name=\"author\" content=\"Anna Monus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anna Monus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. 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.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/\"},\"author\":{\"name\":\"Anna Monus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/a601053a0ab457901e00cdc83bd5359e\"},\"headline\":\"Mastering WordPress Action Hooks for Theme Customization\",\"datePublished\":\"2015-10-06T13:01:38+00:00\",\"dateModified\":\"2024-07-29T16:19:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/\"},\"wordCount\":1750,\"commentCount\":19,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wp-action-hooks-theme-customization\\\/wp-hooks.jpg\",\"keywords\":[\"ad-divi\",\"WordPress Themes\",\"WordPress Tips\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/\",\"name\":\"Mastering WordPress Action Hooks for Theme Customization - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wp-action-hooks-theme-customization\\\/wp-hooks.jpg\",\"datePublished\":\"2015-10-06T13:01:38+00:00\",\"dateModified\":\"2024-07-29T16:19:45+00:00\",\"description\":\"WordPress child themes provide an easy way to customize the appearance of a theme. If the theme's options don't give you enough design choices, you can\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wp-action-hooks-theme-customization\\\/wp-hooks.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/wp-action-hooks-theme-customization\\\/wp-hooks.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-action-hooks-theme-customization\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mastering WordPress Action Hooks for Theme Customization\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/a601053a0ab457901e00cdc83bd5359e\",\"name\":\"Anna Monus\",\"description\":\"Anna is Technical Editor and Writer for Hongkiat.com. She mainly covers front-end frameworks, web standards, accessibility, WordPress development, and UX design.\",\"sameAs\":[\"https:\\\/\\\/www.annalytic.com\\\/\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/anna_monus\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Mastering WordPress Action Hooks for Theme Customization - Hongkiat","description":"WordPress child themes provide an easy way to customize the appearance of a theme. If the theme's options don't give you enough design choices, you can","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.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/","og_locale":"en_US","og_type":"article","og_title":"Mastering WordPress Action Hooks for Theme Customization","og_description":"WordPress child themes provide an easy way to customize the appearance of a theme. If the theme's options don't give you enough design choices, you can","og_url":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2015-10-06T13:01:38+00:00","article_modified_time":"2024-07-29T16:19:45+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg","type":"","width":"","height":""}],"author":"Anna Monus","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Anna Monus","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/"},"author":{"name":"Anna Monus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/a601053a0ab457901e00cdc83bd5359e"},"headline":"Mastering WordPress Action Hooks for Theme Customization","datePublished":"2015-10-06T13:01:38+00:00","dateModified":"2024-07-29T16:19:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/"},"wordCount":1750,"commentCount":19,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg","keywords":["ad-divi","WordPress Themes","WordPress Tips"],"articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/","name":"Mastering WordPress Action Hooks for Theme Customization - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg","datePublished":"2015-10-06T13:01:38+00:00","dateModified":"2024-07-29T16:19:45+00:00","description":"WordPress child themes provide an easy way to customize the appearance of a theme. If the theme's options don't give you enough design choices, you can","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/wp-action-hooks-theme-customization\/wp-hooks.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/wp-action-hooks-theme-customization\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Mastering WordPress Action Hooks for Theme Customization"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/a601053a0ab457901e00cdc83bd5359e","name":"Anna Monus","description":"Anna is Technical Editor and Writer for Hongkiat.com. She mainly covers front-end frameworks, web standards, accessibility, WordPress development, and UX design.","sameAs":["https:\/\/www.annalytic.com\/"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/anna_monus\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-6t4","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/24866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=24866"}],"version-history":[{"count":4,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/24866\/revisions"}],"predecessor-version":[{"id":72427,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/24866\/revisions\/72427"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=24866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=24866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=24866"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=24866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}