I’d check out and give https://github.com/jcchavezs/cmb2-conditionals a try for this. From the looks of it, some extra steps would be needed to make work on the frontend, based on some of the issues I’m reading there.
Hi Michael! I just gave this a quick look, but feel better about tackling this project now after peeking at the example functions file. I’ll be able to dig into it more tomorrow! Thanks so much
Okay, I’ve had a chance to play with the cmb2-conditionals files. Do you have any links to reference those extra steps needed to make it work on the front end?
Thanks Michael!
Please pardon my ignorance here. Can you help me understand why i don’t have to use this technique to display the form fields on the page?
<?php
$text = get_post_meta( $post->ID, '_cmb2_sample_address', true );
echo $text;
echo '<br />';
$text = get_post_meta( $post->ID, '_cmb2_sample_city', true );
echo $text;
echo ', ';
$select = get_post_meta( $post->ID, '_cmb2_sample_state', true );
echo $select;
echo ' ';
$text = get_post_meta( $post->ID, '_cmb2_sample_zip', true );
echo $text;
?>
I followed the CMB2-Snippet-Library/front-end/ example, so everything exists on frontend-form.php; registered objects and fields. And then the shortcode was put on a page in the admin.
I know i’m working on the front-end, not the admin-side of things…but i can’t seem to find an answer to this and i feel like i’m missing a critical connection in my understanding of this.
You can pretend explaining it to a 5 year old…i won’t be offended 🙂
I don’t see anything wrong with that code. That leaves my biggest question being if those are the right meta field keys and if there are values saved in those for the database. Also possible that $post->ID isn’t returning the right or any value, but I have to assume it would be.
Ever get this resolved @eliwbbr ?