To get simple fields (repeatable) to appear on a page, I do the following – in the page template add the following where you want the fields to appear:
<?php $getfields = simple_fields_get_post_group_values(get_the_id(), "Field Group Name", true, 1);
$count = 0;
if($getfields["Field1"][0]!="") {
foreach($getfields["Field1"] as $options) {
echo("field 1 is: " . $getfields["Field1"][$count]);
echo("field 2 is: " . $getfields["Field2"][$count]);
echo("field 3 is: " . $getfields["Field3"][$count]);
$count++; }} ?>
[Please post code snippets between backticks or use the code button.]
Obviously replace “Field Group Name” and “Field1”, “Field2”, “Field3” with the name of the group and fields.
Hope that helps
Thanks JimDestruct…
This gets the basic content to print to the page… but, I have three fields… one is a thumbnail, second is a <h3></h3> and the third is a <p></p>
So:
thumb
h2
p
how would I wrap those tags in the code above? I’m not that proficient in php… any help would be appreciated… Thx
It would just be a case of doing the following (I assume for the thumnail you are using the ‘file’ form field selector in simple fields):
<?php $getfields = simple_fields_get_post_group_values(get_the_id(), "Field Group Name", true, 1);
$count = 0;
if($getfields["Field1"][0]!="") {
foreach($getfields["Field1"] as $options) { ?>
<?php $imgsrc = wp_get_attachment_image_src($getfields["Field1"][$count], 'thumbnail'); ?>
<img src="<?=$imgsrc[0]?>" alt="thumbnail" />
<h2><?php echo($getfields["Field2"][$count])?></h2>
<p><?php echo($getfields["Field3"][$count])?></p>
<?php $count++; }} ?>
So, all you are doing is looping through your repeatable fields and getting the image src of the thumbnail as well as your <h2> and <p> fields then wrapping them in those tags.
Hey JimDestruct… many thanks man… that worked perfectly! I am so surprised at how little information is out there on how to get simple field groups to print in your page! again, many thanks!!!! 🙂
Here’s a link with documentation on this (how to display simple field images within a page): http://eskapism.se/code-playground/simple-fields/tips-and-tricks/
Also, the other tutorials on there are helpful for displaying other types of content.
Thanks mrengy!
Still surprised… I was searching high and low for a plugin that would allow repeating regions with custom fields… I swear this is the only plugin I’ve seen that does this! and very little info on it… thanks again… I’ll check it out!