Answers.Body: <p>Thank to Christians comment, I was able to find a workaround:</p>
  <p>I modified inc/template-tags.php of the twentyseventeen theme, and &quot;faked&quot; being in the loop. Based on Christians description I do not expect any side-effects, as it's only used on the front-page.</p>
  <pre><code>    global $wp_query; // we need the global wp_query to fake being in the loop
      
      if ( get_theme_mod( 'panel_' . $id ) ) {
          $wp_query-&gt;in_the_loop = true; // fake the loop for CiviCRM to work correctly
          $post = get_post( get_theme_mod( 'panel_' . $id ) );
  
  </code></pre>
  <p>This way, the civicrm shortcode get properly executed.
  Thank you.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T22:59:54.533Z
Answers.Text: Rather than modifying the parent theme, use a child theme and supply the modified file there. Otherwise your changes will be overwritten when TwentySeventeen gets updated.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T23:05:10.287Z
Answers.Text: Hmm, actually that's not possible since the function isn't wrapped in `function_exists()`. I'd open a ticket and supply a patch to the theme with `do_action()` calls before and after the relevant code - that way you could fake the loop via the action and revert afterwards.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T23:07:53.253Z
Answers.Text: Either the above, or wrap the function in `function_exists()` :)
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T23:14:22.350Z
Answers.Text: Last (and best) suggestion: use the `parent_theme_file_path` filter to supply your own copy of the `inc/template-tags.php` file. Better than having your code overwritten :) See: https://developer.wordpress.org/reference/hooks/parent_theme_file_path/
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-13T20:25:46.337Z
Answers.Text: thank you for all your help, it's working now.
Answers.UserDisplayName: Flavio C
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T21:11:37.383Z
Answers.LastActivityDate: 2024-01-11T21:11:37.383Z
Answers.UserDisplayName: Flavio C
Answers.Body: <p>The TwentySeventeen theme's &quot;Homepage Sections&quot; functionality isn't implemented using the WordPress <a href="https://developer.wordpress.org/themes/basics/the-loop/" rel="nofollow noreferrer">Loop</a> so attempts to invoke CiviCRM are caught by <a href="https://github.com/civicrm/civicrm-wordpress/blob/bff06d5baaf2c6e9d9037fc07a4d2999c6fe6772/civicrm.php#L1172" rel="nofollow noreferrer">this code</a> which is intended to prevent &quot;double-invoke&quot; situations caused by content-preprocessing plugins e.g. when JetPack &amp; Yoast try to create OpenGraph previews etc. This is vital because invoking CiviCRM more than once will cause a fatal error.</p>
  <p>Unfortunately, there don't appear to be any appropriate hooks in the TwentySeventeen theme whereby you might be able to trick CiviCRM into rendering during the <a href="https://themes.trac.wordpress.org/browser/twentyseventeen/3.4/front-page.php#L49" rel="nofollow noreferrer">Sections pseudo-loop</a>.</p>
  <p>If you're using ACF Pro, what you could do is create the form using ACF Extended and CiviCRM Profile Sync. Alternatively you could use Caldera Forms and the CiviCRM integration plugin.</p>
  <p>Lastly, perhaps there's a way to create the form using FormBuilder and embed it with the CiviCRM Shortcode? The <code>[civicrm component=&quot;afform&quot;]</code> Shortcode doesn't invoke CiviCRM so won't be subject to the same limitations and should render as expected.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T20:51:11.793Z
Answers.Text: Thank you very much for your help - that makes sense, and I suspected something "deeper-down" in the wordpress/civicrm integration. At least I now understand why.
  Could I fake being "in_the_loop()" ?
Answers.UserDisplayName: Flavio C
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T13:39:54.377Z
Answers.LastActivityDate: 2024-01-11T13:39:54.377Z
Answers.UserDisplayName: Christian Wach
Body: <p>I’m using a CIVICRM Form block (type create) to provide a form to the users to subscribe to a newsletter. I want to have this block on the frontpage of my wordpress site. I use the twentyseventeen Theme, which includes other pages on the frontpage as &quot;hovering&quot; blocks. I'm using the &quot;Blocks for CiviCRM&quot; Plugin to add the Form to the page. But using the &quot;[]&quot; Syntax makes no difference. I've tried several options to get the form to display:</p>
  <pre><code>[civicrm component=&quot;profile&quot; mode=&quot;live&quot; hijack=&quot;0&quot; gid=&quot;14&quot;]
  or
  [civicrm component=&quot;profile&quot; mode=&quot;live&quot; hijack=&quot;1&quot; gid=&quot;14&quot;]
  </code></pre>
  <p>I now created a page with just the CiviCRM block in it. When I just display this page, the form is displayed. However when the page is included as a block on the frontpage, nothing is displayed, the civicrm-div is just empty.</p>
  <p>I think that I’m missunderstanding something about how the civicrm integration in wordpress is working, but I can’t find out what… Can you help me?</p>
  <p>Screenshot of the page in the editor:
  <a href="https://i.sstatic.net/7Kzxi.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7Kzxi.png" alt="Page in Editor" /></a></p>
  <p>screenshot of the single page view
  <a href="https://i.sstatic.net/OeTba.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OeTba.png" alt="Form in single Page view" /></a></p>
  <p>emtpy block on the frontpage
  <a href="https://i.sstatic.net/uI09i.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uI09i.png" alt="empty block on the frontpage" /></a></p>
  <p>Thank you for your help!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-09T22:09:34.487Z
Comments.Text: Can you confirm which block plugin you are using?    I use this one  https://lab.civicrm.org/extensions/civicrm-gutenberg-blocks      Can you also tell me what other content is on the front page?   If the block works on a single but not the home/front page it maty be a conflict with other conten, perhaps an other CiviCRM form?
Comments.UserDisplayName: Kevin Cristiano
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-10T12:37:33.163Z
Comments.Text: I was using https://wordpress.org/plugins/blocks-for-civicrm/, I've tried the one you mentioned, but that does not work in the editor at the moment.
Comments.UserDisplayName: Flavio C
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-10T12:43:28.240Z
Comments.Text: But I also doubt, that it's the plugin, because just using the shortcode behaves in the same way.
  
  
  So the main page is a single page with five pages that are included on the front page as hovering layers through the twenty-seventeen "section" option. I'm guessing that the problem is there - maybe the shortcode doesn't get properly interpreted when the page is included as a section as opposed to single page view?
Comments.UserDisplayName: Flavio C
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-11T13:03:46.783Z
Comments.Text: It would be good to know why the plugin I mentioned does not work.  We use on many sites.   If the shortcode behaves the same way there is another issue like a plugin conflict or other content on the home page.  Can you detail what is on the home page in addition to this CiviCRM content?
Comments.UserDisplayName: Kevin Cristiano
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-11T20:56:33.960Z
Comments.Text: Hi Kevin
  There's a problem in the editor. As soon as I click the dropdown to select another profile, the plugin crashes.
  I tried looking through the issues on the github of the plugin, but there seems to be some kind of navigation bar overlay that blocks most of the page...
Comments.UserDisplayName: Flavio C
Tags: <wordpress><forms>
Title: wordpress: signup form not displayed on Frontpage
ThreadText: # wordpress: signup form not displayed on Frontpage
  
  (Asked by: username_0 on 2024-01-09)
  
  I’m using a CIVICRM Form block (type create) to provide a form to the users to subscribe to a newsletter. I want to have this block on the frontpage of my wordpress site. I use the twentyseventeen Theme, which includes other pages on the frontpage as "hovering" blocks. I'm using the "Blocks for CiviCRM" Plugin to add the Form to the page. But using the "[]" Syntax makes no difference. I've tried several options to get the form to display:
  
  ```
  [civicrm component="profile" mode="live" hijack="0" gid="14"]
  or
  [civicrm component="profile" mode="live" hijack="1" gid="14"]
  
  ```
  
  I now created a page with just the CiviCRM block in it. When I just display this page, the form is displayed. However when the page is included as a block on the frontpage, nothing is displayed, the civicrm-div is just empty.
  
  I think that I’m missunderstanding something about how the civicrm integration in wordpress is working, but I can’t find out what… Can you help me?
  
  Screenshot of the page in the editor:
  [![Page in Editor](https://i.sstatic.net/7Kzxi.png)](https://i.sstatic.net/7Kzxi.png)
  
  screenshot of the single page view
  [![Form in single Page view](https://i.sstatic.net/OeTba.png)](https://i.sstatic.net/OeTba.png)
  
  emtpy block on the frontpage
  [![empty block on the frontpage](https://i.sstatic.net/uI09i.png)](https://i.sstatic.net/uI09i.png)
  
  Thank you for your help!
  
  **Tags:** wordpress, forms
  
  > **Comments:**
  > **username_1**: Can you confirm which block plugin you are using?    I use this one  https://lab.civicrm.org/extensions/civicrm-gutenberg-blocks      Can you also tell me what other content is on the front page?   If the block works on a single but not the home/front page it maty be a conflict with other conten, perhaps an other CiviCRM form?  
  > **username_0**: I was using https://wordpress.org/plugins/blocks-for-civicrm/, I've tried the one you mentioned, but that does not work in the editor at the moment.  
  > **username_0**: But I also doubt, that it's the plugin, because just using the shortcode behaves in the same way.   So the main page is a single page with five pages that are included on the front page as hovering layers through the twenty-seventeen "section" option. I'm guessing that the problem is there - maybe the shortcode doesn't get properly interpreted when the page is included as a section as opposed to single page view?  
  > **username_1**: It would be good to know why the plugin I mentioned does not work.  We use on many sites.   If the shortcode behaves the same way there is another issue like a plugin conflict or other content on the home page.  Can you detail what is on the home page in addition to this CiviCRM content?  
  > **username_0**: Hi username_1 There's a problem in the editor. As soon as I click the dropdown to select another profile, the plugin crashes. I tried looking through the issues on the github of the plugin, but there seems to be some kind of navigation bar overlay that blocks most of the page...  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2024-01-11. Score: 0 | Accepted answer
  
  Thank to Christians comment, I was able to find a workaround:
  
  I modified inc/template-tags.php of the twentyseventeen theme, and "faked" being in the loop. Based on Christians description I do not expect any side-effects, as it's only used on the front-page.
  
  ```
      global $wp_query; // we need the global wp_query to fake being in the loop
      
      if ( get_theme_mod( 'panel_' . $id ) ) {
          $wp_query->in_the_loop = true; // fake the loop for CiviCRM to work correctly
          $post = get_post( get_theme_mod( 'panel_' . $id ) );
  
  ```
  
  This way, the civicrm shortcode get properly executed.
  Thank you.
  
  > **Comments:**
  > **username_2**: Rather than modifying the parent theme, use a child theme and supply the modified file there. Otherwise your changes will be overwritten when TwentySeventeen gets updated.  
  > **username_2**: Hmm, actually that's not possible since the function isn't wrapped in `function_exists()`. I'd open a ticket and supply a patch to the theme with `do_action()` calls before and after the relevant code - that way you could fake the loop via the action and revert afterwards.  
  > **username_2**: Either the above, or wrap the function in `function_exists()` :)  
  > **username_2**: Last (and best) suggestion: use the `parent_theme_file_path` filter to supply your own copy of the `inc/template-tags.php` file. Better than having your code overwritten :) See: https://developer.wordpress.org/reference/hooks/parent_theme_file_path/  
  > **username_0**: thank you for all your help, it's working now.  
  
  ---
  
  ### Answer by username_2 on 2024-01-11. Score: 2
  
  The TwentySeventeen theme's "Homepage Sections" functionality isn't implemented using the WordPress [Loop](https://developer.wordpress.org/themes/basics/the-loop/) so attempts to invoke CiviCRM are caught by [this code](https://github.com/civicrm/civicrm-wordpress/blob/bff06d5baaf2c6e9d9037fc07a4d2999c6fe6772/civicrm.php#L1172) which is intended to prevent "double-invoke" situations caused by content-preprocessing plugins e.g. when JetPack & Yoast try to create OpenGraph previews etc. This is vital because invoking CiviCRM more than once will cause a fatal error.
  
  Unfortunately, there don't appear to be any appropriate hooks in the TwentySeventeen theme whereby you might be able to trick CiviCRM into rendering during the [Sections pseudo-loop](https://themes.trac.wordpress.org/browser/twentyseventeen/3.4/front-page.php#L49).
  
  If you're using ACF Pro, what you could do is create the form using ACF Extended and CiviCRM Profile Sync. Alternatively you could use Caldera Forms and the CiviCRM integration plugin.
  
  Lastly, perhaps there's a way to create the form using FormBuilder and embed it with the CiviCRM Shortcode? The `[civicrm component="afform"]` Shortcode doesn't invoke CiviCRM so won't be subject to the same limitations and should render as expected.
  
  > **Comments:**
  > **username_0**: Thank you very much for your help - that makes sense, and I suspected something "deeper-down" in the wordpress/civicrm integration. At least I now understand why. Could I fake being "in_the_loop()" ?  
  
  ---
  
  