WordPress.org

Support

Support » Plugins and Hacks » how to post in page…

how to post in page…

  • I am new to WordPress… never used it before and just checking it out… after looking I can’t seem to find a clear answer to “how do you get the fields to display in your page? ( this is a repeating region of three fields ) I’ve looked at custom field keys etc… but can’t find a simple example on how to display the fields on the page…

    can someone illustrate a simple way to get a simple fields repeating group to appear on the page? ( front end ) pleeeeease?

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to post in page…’ is closed to new replies.