Site logo

Archived topic

Display metaboxes created with Meta Box Online Generator

7 replies · Started by Eva on September 19, 2018

Viewing posts 1–8 of 8

Hi!
I have created some meta boxes with the Meta Box Online Generator. I can see and use the meta boxes in the backend, but can’t get them displayed. I found this info in the Meta Box documentation:

To get custom field value in WordPress or display it in your theme, copy the following code and paste it in your theme’s template file:
$value = rwmb_meta( $field_id );
echo $value;
You can put it in the theme single.php or template-parts/content.php file

Can you please tell me where I should add the code in GP?
Thank you,
Eva

Hi Eva,

That depends on what the code is doing exactly. Are you trying to print data on the page? If so, where?

Hi Tom,
I am trying to display the content of the boxes in my CPT's. I am using a child theme (as you might know from my other topic :-).

Where in the theme are you trying to display the content? After the page content? In the header?

Where depends on how we add it to the theme :)

After the content...

So you could go to "Elements > Add New > Hook" and add your code into the hook content:

<?php
$value = rwmb_meta( $field_id );

if ( $value ) {
    echo $value;
}
?>

Then choose the after_content hook, and check the Execute PHP checkbox.

Just a note that the above $field_id value needs to have a value, or be switched to an actual value.

Let me know :)

Thanks!!
I tried, but I think I will let this rest for a minute because it's not super necessary for the site I am making.
If and when I move on with this feature, I get back to you.
Thanks for now!

No problem :)

This archived topic is closed to new replies.