Support

Account

Home Forums Front-end Issues Newbie Help – Nested queries

Solved

Newbie Help – Nested queries

  • Hi All,

    New to ACF, but getting there.

    I have the the follwoing:

    ACF Field Group: Home Page (HP)

    ACF Field Group: Case Study (CS)

    I’m building a homepage template which pulls everything from the group HP

    I also need to include a section midway down that pulls in the latest entry from CS, i.e.:

    HEADER

    HP Title
    HP Hero Image

    HP Intro

    CS Title
    CS Hero Image

    HP Call to Action
    HP End Block

    FOOTER

    PROBLEM:

    Running a query midway in the template against CS does not allow me to access any of the info in there

    Query:

     $ps = get_posts(
    	array(
    	'numberposts' => -1,
    	'post_type' => 'case_study',
    	'posts_per_page' => '1',
    	)
    );

    Accessing anything through the_field(‘cs_title’) comes up with nothing, as the HP query is the only data accessible.

    How do I separate the CS query into it’s own namespace to be able to access the field values whilst in the middle of the HP query?

    Any pointers?

    Ben

  • UPDATE:

    I’m an idiot. I wasn’t referencing the case study object in my display loop.

    I will go an sit in a corner now.

    Sorry!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.