Support Forum
Support › General › // Metabox.io https://docs.metabox.io/displaying-fields/ blank page errorResolved
Hi Ahn - I'm testing the Mailpoet plugin, and am having a display issue when the a user is redirected back to the site to confirm a newsletter subscription.
Here's the link structure where this is happening:
https://[my-site]/?mailpoet_page=subscriptions&mailpoet_router&endpoint=subscription&action=confirm&data=eyJ0b2tlbiI6IjkzOGVkNyIsImVtYWlsIjoibGlhbWdtYXNAZ21haWwuY29tIn0
The page is displaying a blank page with only the following:
// Metabox.io https://docs.metabox.io/displaying-fields/
The following is in my single.php theme file:
<?php
$value = rwmb_meta( $field_id );
echo $value;
?>
What's causing this, do you think?
Thanks,
Sam
Hi Sam,
Could you please share full the code of the file single.php
? For example https://pastebin.com/91cF37zN
And the function rwmb_meta( $field_id );
only works inside the loop. If you want to display the field value outside the loop, please use more arguments like this rwmb_meta( $field_id, $args, $post_id );
Hi Long!
I've added your additional arguments to my theme child's single.php, and it's still not working.
Here's code from single.php (child): https://pastebin.com/AKTabuC8
Here's code from single.php (theme): https://pastebin.com/PCukrUah
And to refresh your memory, this display issue is coming as a result of a new plugin's auto-generated links (mailpoet3 plugin, btw).
Thank you!
Sam
Hi Sam,
If you display the field outside the loop, please replace the variable
$field_id
with the ID of the field, for example, https://docs.metabox.io/fields/text/#sample-code ID is text
$args
if you do not use any arguments, leave it blank
$post_id
with the ID (number) of the post, you can get it when editing the post and see on the URL wp-admin/post.php?post=2482&action=edit
the code would be rwmb_meta( 'text', '', '2482' );
Hi Long - I get what you're suggesting, but if you take a look at the example I provided originally
https://[my-site]/?mailpoet_page=subscriptions&mailpoet_router&endpoint=subscription&action=confirm&data=eyJ0b2tlbiI6IjkzOGVkNyIsImVtYWlsIjoibGlhbWdtYXNAZ21haWwuY29tIn0)
it doesn't have a $field_id or $post_id. It's auto-generated by the plugin (I've seen other plugins do this as well).
So as you can see in the link example above, there's neither a $field_id nor a $post_id, right? Then how do I attack this instead? As you can tell, I'm stumped.
Thanks,
Sam
Hi Sam,
Please take a look at the short screen record to know how to get the $field_id
and $post_id
then you can add the code to display the field value to anywhere.