{"id":150,"date":"2024-03-18T10:44:55","date_gmt":"2024-03-18T13:44:55","guid":{"rendered":"https:\/\/kylekelly.com\/?p=150"},"modified":"2024-03-18T10:45:17","modified_gmt":"2024-03-18T13:45:17","slug":"wordpress-render_block-filter","status":"publish","type":"post","link":"https:\/\/kylekelly.com\/posts\/wordpress-render_block-filter\/","title":{"rendered":"WordPress render_block filter to remove all links from post-terms"},"content":{"rendered":"\n

I just needed to remove all links from all post terms blocks (for reasons). The filter render_block_{$this->name}<\/code> is such a great resource for modifying core blocks and made it so simple to do.<\/p>\n\n\n\n

add_filter('render_block_core\/post-terms', function($block_content, $block) {\n\treturn preg_replace('\/\\<a (.*?)\\>\/', '', $block_content);\n}, 10, 2);<\/code><\/pre>\n\n\n\n

If you’re doing any kind of work with blocks in WP as a dev, it pays to have this filter always at the ready: https:\/\/developer.wordpress.org\/reference\/hooks\/render_block_this-name\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

I just needed to remove all links from all post terms blocks (for reasons). The filter render_block_{$this->name} is such a great resource for modifying core blocks and made it so simple to do. If you’re doing any kind of work with blocks in WP as a dev, it pays to have this filter always at […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[4,9],"_links":{"self":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts\/150"}],"collection":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":3,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts\/150\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}