Recipe for displaying site field sets?

This topic is: resolved
Viewing 8 posts - 1 through 8 (of 8 total)
Author Posts
June 29, 2013 at 2:03 am #3253
Post count: 11

Hi, not sure if this is a question or suggestion but is there a ‘code recipe’ for accessing field sets not associated with a post/page/type – ie Site Field Sets? That would be very helpful.

In particular, I’m trying to loop through a multi-item field set in the Site Field Sets. I think the loop is working correctly, but it’s returning two blank records instead of the images:

This code is in my footer.php file:

My Site Field Set is set up like htis:
-> logo_image
-> logo_link
-> hover_text

Thanks for your help!

June 29, 2013 at 4:14 am #3255
Post count: 11

Okay, I’ve made a bit of progress. Using this code within the foreach loop, I can get an img tag to spit out:

echo $wf->site->field(“footer_icons.logo_image”);

BUT, the path to the image is incorrect – it doesn’t account for me working on a Windows localhost/WAMP installation and uses backslashes instead of forward slashes for the latter half of the URL:


Any ideas? Thank you!

(PS I have updated to the latest beta to see if that fixed it but nothing changed.)

  • This reply was modified 7 years, 8 months ago by AvatarMichelle.
June 29, 2013 at 4:50 pm #3259
Post count: 207

You’re quite right about the site code, that’s exactly how you do it 🙂

Sorry about the image path thing – will check this in Windows again, and let you know when a fix is available.

June 29, 2013 at 4:51 pm #3260
Post count: 207

Actually, you don’t have to call “field” strictly in your code. Can also do:


July 3, 2013 at 2:18 am #3263
Post count: 11

Cool, thanks! I’ll look for the update – it’s making developing the site pretty tough not to have that working. 🙂

July 3, 2013 at 2:33 am #3264
Post count: 11

Oh – and sorry – I’m still not getting how this should work, even if the paths were correct. See this pastebin for my updated code:

When I use this, it doesn’t loop correctly; it just outputs the first submitted entry multiple times. I tried using the code from example #4 on this page: (see my original Pastebin above) but that didn’t work either. What am I missing?



July 3, 2013 at 5:26 pm #3268
Post count: 207

Hey Michelle,

The code for the loop is slightly wrong. By reaccessing $wf->site->footer_logos, you’re actually accessing only the first item in that set each time. This is by design – we decided that if you access a field in a multi-item set like that, it would access the field from the first record in the set, which can be handy at times.

You need to use the $footer_logo loop variable each time, so your code should look something like this:

Hope that helps.

I still haven’t had a chance to check the Windows issue, but will look at it soon. Sorry!

July 4, 2013 at 4:16 am #3269
Post count: 11

Thanks so much Travis! That (+ the WAMP path fix) works great. Whew! 🙂

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

You must be logged in to reply to this topic.

Latest From the Blog

MasterPress 1.2.8 is now available

It was brought to our attention that MasterPress would give a tonne of warnings and deprecation notices when used with PHP 7.4 – this update addresses those.

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the hosted service.

Three AM