{"id":380,"date":"2026-04-27T08:34:28","date_gmt":"2026-04-27T06:34:28","guid":{"rendered":"https:\/\/themify.hznknd.de\/layout-part-inserted-via-a-hook-doesnt-work\/"},"modified":"2026-04-27T08:34:28","modified_gmt":"2026-04-27T06:34:28","slug":"layout-part-inserted-via-a-hook-doesnt-work","status":"publish","type":"post","link":"https:\/\/themify.hznknd.de\/en\/layout-part-inserted-via-a-hook-doesnt-work\/","title":{"rendered":"Layout part inserted via a hook doesn\u2019t work"},"content":{"rendered":"<h3>The actual problem: WPML + Themify Builder is not maintainable<\/h3>\n<p>We run a multilingual website with WPML and dozens of pages in multiple languages. Two bugs make this setup unmaintainable in practice:<\/p>\n<ul>\n<li>Hook Content Conditions set for the original page never apply to translated pages \u2013 each condition would have to be manually duplicated for each translation<\/li>\n<li>Builder styles do not automatically synchronize to translated pages \u2013 editors must manually open each translated page in the Builder after every layout change to apply the styles<\/li>\n<\/ul>\n<p>Both problems have the same cause: Themify Builder does not fully utilize the integration APIs provided by WPML.<\/p>\n<hr>\n<h3>Background: How WPML manages pages<\/h3>\n<p>WPML links pages across languages via translation relationships, which are accessible through a dedicated API:<\/p>\n<pre><code>\/\/ \u00dcbersetzung einer Seite in einer anderen Sprache ermitteln\n$translated_id = apply_filters('wpml_object_id', $post_id, 'page', false, $lang);\n\n\/\/ Aktuelle \/ Standard-Sprache abfragen\n$current_lang = apply_filters('wpml_current_language', null);\n$default_lang  = apply_filters('wpml_default_language', null);<\/code><\/pre>\n<p>These APIs exist precisely so that plugins can work WPML-compatible without duplicating logic per language.<\/p>\n<hr>\n<h3>Bug 1: Hook Content Conditions do not apply to translated pages<\/h3>\n<p>In  <code>themify\/class-hook-contents.php<\/code>  builds  <code>check_visibility()<\/code>  the breadcrumb trail via  <code>child_post_name()<\/code>:<\/p>\n<pre><code>\/\/ class-hook-contents.php ~Zeile 179\nin_array( '\/' . self::child_post_name( $query_object ) . '\/', $posts )<\/code><\/pre>\n<p><code>child_post_name()<\/code>  recursively runs over <code>post_parent<\/code> and concatenates the <code>post_name<\/code> values. On a translated page, this returns the <strong>English slug<\/strong>, e.g.:<\/p>\n<pre><code>\/services\/production-and-delivery-of-green-hydrogen\/<\/code><\/pre>\n<p>However, the saved Visibility Condition contains the <strong>German slug (default language)<\/strong>:<\/p>\n<pre><code>\/leistungen\/produktion-und-lieferung-von-gruenem-wasserstoff\/<\/code><\/pre>\n<p>The <code>in_array()<\/code> comparison always fails \u2192 Hook Content is never output on translated pages.<\/p>\n<p><strong>Expected Fix<\/strong> \u2013 resolve to the original language version before comparison:<\/p>\n<pre><code>$original_id   = apply_filters('wpml_object_id', $query_object-&gt;ID, 'page', false, $default_lang);\n$original_post = get_post($original_id);\n$original_path = '\/' . self::child_post_name($original_post) . '\/';\n\nin_array($original_path, $posts)<\/code><\/pre>\n<p>We solved this as a workaround via <code>template_redirect<\/code> with priority 11 and manually register the missing <code>add_action()<\/code> calls. It works\u2014but it should be fixed in <code>check_visibility()<\/code> itself.<\/p>\n<hr>\n<h3>Bug 2: Builder styles don\u2019t sync to translated pages<\/h3>\n<p>When a layout is updated in the default language (German), Themify Builder saves the result in the post meta:<\/p>\n<pre><code>_themify_builder_settings_json<\/code><\/pre>\n<p>WPML\u2019s page builder integration should automatically transfer this value to translated pages when saving. In practice, the <strong>grid structure<\/strong> syncs correctly, but the <strong>styles do not<\/strong>. The translated page only picks up changed styles after it has been opened manually in the builder.<\/p>\n<p>WPML provides a dedicated hook for this:<\/p>\n<pre><code>do_action('wpml_page_builder_string_translated', $package_name, $translated_post_id, $data, $lang);<\/code><\/pre>\n<p>Somewhere in the handoff between Themify Builder\u2019s save routine and WPML\u2019s sync mechanism, something is missing\u2014either the style data isn\u2019t written to the translation\u2019s post meta, or the extraction step is skipped during sync.<\/p>\n<hr>\n<p>The suggested workaround (adding every translated page manually as an additional hook content condition) doesn\u2019t solve either problem\u2014it just shifts the maintenance effort to the editors. A systematic fix using the existing WPML integration APIs would be the right approach.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The actual problem: WPML + Themify Builder is not maintainable We run a multilingual website with WPML and dozens of pages in multiple languages. Two bugs make this setup unmaintainable in practice: Hook Content Conditions set for the original page never apply to translated pages \u2013 each condition would have to be manually duplicated for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-380","post","type-post","status-publish","format-standard","hentry","category-themify-ultra-pro-builder-bugs","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/comments?post=380"}],"version-history":[{"count":0,"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/posts\/380\/revisions"}],"wp:attachment":[{"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/media?parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/categories?post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themify.hznknd.de\/en\/wp-json\/wp\/v2\/tags?post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}