Home › Forums › General Issues › Pass the Post ID to another page › Reply To: Pass the Post ID to another page
Ok, I got this to work. My code was actually working, I just was not able to pull in the parameter the way I originally wanted (or thought that I could). What I did was pass the Post ID parameter through the URL and then pull that parameter into my style template. Here is what I did in case it helps anyone in the future:
I passed the Post ID into the url (I.E. http://www.mysite.com/processform/?postid=1234).
I added this to my style template:
<?php
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ;
$parts = parse_url($url);
parse_str($parts['query'], $query);
$mypostid = $query['postid'];
?>
and this is how my repeater fields looked:
<?php if(get_field('choice_menu', $mypostid)): $i = 0;?>
<?php while(has_sub_field('choice_menu', $mypostid)): $i++;?>
<p><?php the_sub_field('choice_name'); ?> : $check<?php echo $i; ?></p>
<?php endwhile; ?>
<?php endif; ?>
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.