Domanda

I’ve got a problem that’s a little tricky to explain.

I’m building a custom wordpress site and am having trouble with one page template specifically.

I’m using custom fields (set up with advanced custom fields plugin) to pull in content from the page editor and in this page I’m also using WP_Query several times to pull in feeds of a custom post types (several taxonomies).

I’ll try and diagram the structure of my page below but the problem seems to be that none of the custom fields work after the first of the WP_Query loops has ended. Quick literally they are not finding any content. My theory is that there is confusion happening between the end of the WP_Query loop and the page WP Loop. However I am a complete php rookie so this is just a wild guess.

Here’s the structure of my page:

<--Page Template-->
<--Standard WP Loop--> 

<— Page content —>
<— Custom fields working fine e.g. <?php the_field(‘heading_1’) ?> —>

<--WP_Query custom loop 1 -->
<— custom post html/content —>
<--/ end of WP_Query custom loop-->

<— Page content —>
<— Custom fields NOT WORKING —>

<--WP_Query custom loop 2 -->
<— custom post html/content —>
<--/ end of WP_Query custom loop-->

<— Page content —>
<— Custom fields NOT WORKING —>

<--/ End of Standard WP Loop-->
<--/ End of Page Template-->

There are 5 WP_Query loops in total but the custom fields stop working after the first. I would post the code but it’s 300+ lines long. Page url is: http://dev.tps.entropii.com/media/

Any help would be most appreciated.

È stato utile?

Soluzione

Like Hobo said, try resetting each query with wp_reset_query()

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top