// Metabox.io https://docs.metabox.io/displaying-fields/ blank page error
Support › General › // Metabox.io https://docs.metabox.io/displaying-fields/ blank page errorResolved
- This topic has 5 replies, 2 voices, and was last updated 5 years, 7 months ago by
Long Nguyen.
-
AuthorPosts
-
April 19, 2020 at 9:59 PM #19110
Sam
ParticipantHi 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=eyJ0b2tlbiI6IjkzOGVkNyIsImVtYWlsIjoibGlhbWdtYXNAZ21haWwuY29tIn0The 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
April 20, 2020 at 10:23 AM #19149Long Nguyen
ModeratorHi Sam,
Could you please share full the code of the file
single.php? For example https://pastebin.com/91cF37zNAnd 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 thisrwmb_meta( $field_id, $args, $post_id );April 29, 2020 at 7:55 AM #19352Sam
ParticipantHi 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/PCukrUahAnd 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!
SamApril 29, 2020 at 10:27 AM #19356Long Nguyen
ModeratorHi Sam,
If you display the field outside the loop, please replace the variable
$field_idwith the ID of the field, for example, https://docs.metabox.io/fields/text/#sample-code ID istext
$argsif you do not use any arguments, leave it blank
$post_idwith 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=editthe code would be
rwmb_meta( 'text', '', '2482' );April 29, 2020 at 10:39 AM #19359Sam
ParticipantHi 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,
SamApril 29, 2020 at 4:53 PM #19366Long Nguyen
ModeratorHi Sam,
Please take a look at the short screen record to know how to get the
$field_idand$post_idthen you can add the code to display the field value to anywhere. -
AuthorPosts
- You must be logged in to reply to this topic.