{"id":4554,"date":"2026-04-16T12:49:28","date_gmt":"2026-04-16T09:49:28","guid":{"rendered":"https:\/\/fastpixel.io\/?post_type=docs&#038;p=4554"},"modified":"2026-04-16T13:19:17","modified_gmt":"2026-04-16T10:19:17","password":"","slug":"fastpixel-hooks","status":"publish","type":"docs","link":"https:\/\/fastpixel.io\/fr\/docs\/fastpixel-hooks\/","title":{"rendered":"FastPixel &#8211; Hooks"},"content":{"rendered":"<p>FastPixel provides WordPress action hooks that allow developers to programmatically trigger cache purges and react to cache events. This is useful when integrating FastPixel with custom plugins, WooCommerce, ACF, or any workflow that modifies content outside the standard WordPress editor.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Trigger Hooks<\/h2>\n\n\n\n<p>Use these hooks to <strong>initiate<\/strong> a cache purge from your own code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/purge\/all<\/code><\/h3>\n\n\n\n<p>Purges the entire site cache. Equivalent to clicking &#8220;Purge All Cache&#8221; in the FastPixel admin panel.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong> None<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>do_action('fastpixel\/purge\/all');<\/code><\/pre>\n\n\n\n<p><strong>Use case \u2013 Purge everything when ACF options page is saved:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('acf\/save_post', function($post_id) {\n    if ($post_id === 'options') {\n        do_action('fastpixel\/purge\/all');\n    }\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/purge\/single<\/code><\/h3>\n\n\n\n<p>Purges the cache for a single post, page, or taxonomy term.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Required<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>id<\/code><\/td><td><code>int<\/code><\/td><td>Yes<\/td><td>The post ID or term ID to purge<\/td><\/tr><tr><td><code>type<\/code><\/td><td><code>string<\/code><\/td><td>No<\/td><td><code>'posts'<\/code> or <code>'taxonomies'<\/code>. Auto-detected if omitted.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Examples:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Purge a post (type is auto-detected)\ndo_action('fastpixel\/purge\/single', &#91;'id' =&gt; 123]);\n\n\/\/ Purge a taxonomy term\ndo_action('fastpixel\/purge\/single', &#91;'id' =&gt; 45]);\n\n\/\/ Explicitly specify the type\ndo_action('fastpixel\/purge\/single', &#91;'id' =&gt; 123, 'type' =&gt; 'posts']);\ndo_action('fastpixel\/purge\/single', &#91;'id' =&gt; 45, 'type' =&gt; 'taxonomies']);<\/code><\/pre>\n\n\n\n<p><strong>Use case \u2013 Purge a WooCommerce product when stock changes:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('woocommerce_product_set_stock', function($product) {\n    do_action('fastpixel\/purge\/single', &#91;'id' =&gt; $product-&gt;get_id()]);\n});<\/code><\/pre>\n\n\n\n<p><strong>Use case \u2013 Purge a post when its custom meta is updated:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('updated_post_meta', function($meta_id, $post_id, $meta_key) {\n    if ($meta_key === 'my_custom_field') {\n        do_action('fastpixel\/purge\/single', &#91;'id' =&gt; $post_id]);\n    }\n}, 10, 3);<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/purge\/url<\/code><\/h3>\n\n\n\n<p>Purges the cache for a specific URL. Useful for pages that aren&#8217;t tied to a post ID, such as custom routes or archive pages.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Required<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$url<\/code><\/td><td><code>string<\/code><\/td><td>Yes<\/td><td>The full URL to purge<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Examples:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Purge a specific URL\ndo_action('fastpixel\/purge\/url', 'https:\/\/example.com\/my-landing-page\/');\n\n\/\/ Purge the homepage\ndo_action('fastpixel\/purge\/url', home_url('\/'));<\/code><\/pre>\n\n\n\n<p><strong>Use case \u2013 Purge a custom archive page when a related CPT is saved:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('save_post_event', function($post_id) {\n    if (get_post_status($post_id) === 'publish') {\n        do_action('fastpixel\/purge\/url', home_url('\/events\/'));\n    }\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">After-Purge Hooks<\/h2>\n\n\n\n<p>Use these hooks to <strong>react<\/strong> after a cache purge has already occurred. These are useful for logging, sending notifications, or chaining additional actions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/purge_all<\/code><\/h3>\n\n\n\n<p>Fires after the entire cache has been purged.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong> None<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('fastpixel\/purge_all', function() {\n    error_log('FastPixel: full cache was purged at ' . current_time('mysql'));\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/backend\/purged\/single\/post<\/code><\/h3>\n\n\n\n<p>Fires after a single post&#8217;s cache has been purged.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$post<\/code><\/td><td><code>WP_Post<\/code><\/td><td>The WordPress post object that was purged<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('fastpixel\/backend\/purged\/single\/post', function($post) {\n    error_log('FastPixel: cache purged for post #' . $post-&gt;ID . ' (' . $post-&gt;post_title . ')');\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/backend\/purged\/single\/term<\/code><\/h3>\n\n\n\n<p>Fires after a taxonomy term&#8217;s cache has been purged.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$term<\/code><\/td><td><code>WP_Term<\/code><\/td><td>The WordPress term object that was purged<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('fastpixel\/backend\/purged\/single\/term', function($term) {\n    error_log('FastPixel: cache purged for term #' . $term-&gt;term_id);\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><code>fastpixel\/backend\/purged\/single\/by_url<\/code><\/h3>\n\n\n\n<p>Fires after a specific URL&#8217;s cache has been purged.<\/p>\n\n\n\n<p><strong>Parameters:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$url<\/code><\/td><td><code>string<\/code><\/td><td>The URL that was purged<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('fastpixel\/backend\/purged\/single\/by_url', function($url) {\n    error_log('FastPixel: cache purged for URL ' . $url);\n});<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>FastPixel provides WordPress action hooks that allow developers to programmatically trigger cache purges and react to cache events. This is useful when integrating FastPixel with custom plugins, WooCommerce, ACF, or any workflow that modifies content outside the standard WordPress editor. Trigger Hooks Use these hooks to initiate a cache purge from your own code. fastpixel\/purge\/all [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"doc_category":[13],"doc_tag":[],"class_list":["post-4554","docs","type-docs","status-publish","hentry","doc_category-fastpixel-website-accelerator"],"blocksy_meta":[],"year_month":"2026-04","word_count":548,"total_views":"15","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Adrian","author_nicename":"adrian","author_url":"https:\/\/fastpixel.io\/fr\/blog\/author\/adrian\/"},"doc_category_info":[{"term_name":"FastPixel Website Accelerator","term_url":"https:\/\/fastpixel.io\/fr\/docs-category\/fastpixel-website-accelerator\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false,"betterdocs-category-thumb":false},"uagb_author_info":{"display_name":"Adrian","author_link":"https:\/\/fastpixel.io\/fr\/blog\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"FastPixel provides WordPress action hooks that allow developers to programmatically trigger cache purges and react to cache events. This is useful when integrating FastPixel with custom plugins, WooCommerce, ACF, or any workflow that modifies content outside the standard WordPress editor. Trigger Hooks Use these hooks to initiate a cache purge from your own code. fastpixel\/purge\/all\u2026","_links":{"self":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/comments?post=4554"}],"version-history":[{"count":1,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4554\/revisions"}],"predecessor-version":[{"id":4555,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4554\/revisions\/4555"}],"wp:attachment":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/media?parent=4554"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/doc_category?post=4554"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/doc_tag?post=4554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}