How to display data from cmb2 option page?
-
I have created a repeatable field with CMB2, and created a normal field. This is the function of https://pastebin.com/XUQgkvbi
If you use foreach for repeatable using a post or page then you can show data as: https://pastebin.com/C35vWGDs
And Call normal field without repeatable, then
also work.
But the problem is, I do not want to use the above function on any page or post. I want to use it in the Options Page. The above Function option has been added to the option page, but I can not do the data show of those files in any way. I’ve tried get_post_meta () and get_option () with two functions, but in no way can I show data from the option page. How can I get the data from the above fields (option page) to the show in the frontend? Please help with a little bit.
I have tried to lot of way for show data from option page, but i can’t success
#Way One
<?php $entries = get_post_meta(get_the_ID() , 'news-section', true); foreach((array)$entries as $key => $entry) { $title = $content = ''; if ( isset( $entry[ 'title' ] ) ) $title = esc_html( $entry[ 'title' ] ); if ( isset( $entry[ 'description' ] ) ) $content = $entry[ 'description' ]; if ( !empty($title) ) { echo '<h3> ' .$title . '</h3>'; } if ( !empty($content) ) { echo $content; } } //* end foreach; ?>
#Way two
`<?php $entries = get_post_meta( get_the_ID(), ‘news-sectiono’, true ); ?>
<?php print_r($entries); ?><?php foreach($entries as $content) : ?>
<?php echo $content[‘title’].'<br/>’; ?>
<?php endforeach; ?>`#way three
way two with loop
I have also tried using get_meta_box() and get_option() functions.
i have tried using get_option() not myprefix_get_option() because I don’t any prefix. please help me, i have searched lot of on google, i trying to fixing this problem from 2 days ago, but still i can’t success. please help me.
- The topic ‘How to display data from cmb2 option page?’ is closed to new replies.