I am close to a solution, I have the true/false working but need the else piece of the puzzle to post to page id 235. any idea?
<?php if( have_rows('active_studies', 14) ): ?>
<?php while ( have_rows('active_studies', 14) ) : the_row(); ?>
<?php
// check if box is ticked
if( get_sub_field('complete_study') )
{
echo '<h1>'.the_sub_field('title').'</h1>',
'<h2>'.the_sub_field('investigator_name').'</h2>',
'<h2><i>'.the_sub_field('organization(s)').'</i></h2>',
'<p>'.the_sub_field('summary').'</p>',
'<h3>'.the_sub_field('related_content_title').'</h3>',
'<p style="color: #666666;">'.the_sub_field('related_content').'</p>';
}
else
{
echo "do something else";
}
?>
<?php endwhile;
else :
// no rows found
endif;
?>
I understand getting page A data and the $post_id parameter. I think now I am confused on how page B will actually display that data on the page. All of my other custom field content uses the Location and Rules to display. So what PHP would I add to my template file that says:
on page B post the following:
<?php if( have_rows('active_studies', 14) ): ?>
<?php while ( have_rows('active_studies') ) : the_row(); ?>
<h1><?php the_sub_field('title'); ?></h1>
<h2><?php the_sub_field('investigator_name'); ?></h2>
<h2><i><?php the_sub_field('organization(s)'); ?></i></h2>
<p><?php the_sub_field('summary'); ?></p>
<h3><?php the_sub_field('related_content_title'); ?></h3>
<p style="color: #666666;"><?php the_sub_field('related_content'); ?></p>
<?php endwhile;
else :
// no rows found
endif;
?>
1. Repeater field with a text sub-field type and a true_false sub-field.
2. this is a sub-field
3. the content entered in the text field.
4. Page B is a wordpress page which wont have any user content loaded from the standard wordpress CMS or any fields shown from ACS. The data from 1 row of the repeater on page A will auto populate on page B if the true_false checkbox is checked in that row.
5. Page A is accessed from a link on the website. Page B will be accessed from a link on page A.
6. The content in the subfields in the repeater will either post to page A or B depending on if the checkbox is checked. But all of the rows will always be managed from a “wordpress page” in the wordpress admin. I am using a rule to show if field group is equal to page A.
Hopefully this clarified everything.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.