Site logo

Archived topic

Can you use the Meta Box ID for Elements custom field template tag

4 replies · Started by Joshua on July 17, 2020

Viewing posts 1–5 of 5

I'm using the Meta Box plugin, but for some reason the data in the custom field isn't displaying on the front end.

On the Meta Box online generator, I create a test field with an ID of Test_Name. I add the meta box code to my functions.php. Then I go to the test post and add some fake data into the new test field.

Then, I go to my post header template in Elements, and I change out the title template tag of {{custom_field.Reviews_Title}} to {{custom_field.Test_Name}}. However, when I look at the front end, the data that's in the Test_Name field isn't showing up.

Any suggestions?

Hi there,

I wonder if they do something with the ID.

Does this output anything in your functions.php?:

$custom_field = get_post_meta( get_the_ID(), 'Test_Name', true );
var_dump($custom_field);

Hi Tom,

Thanks for your reply. That didn't seem to change anything. Honestly, I'm just going to dump using the plugin and stick with the the core custom fields feature.

I was only using the meta box plugin to better organize my custom fields, but it's not 100% necessary for what I want to accomplish on the front end.

Thank you for your help, Tom!

Actually, I figured it out.

By default, it adds a Field ID prefix. The default prefix was "prefix-". This means instead of just entering "Test_Name" into the Elements header, I would have to enter "prefix-Test_Name" to get the data to display on the front end.

Alternatively, I can just delete the prefix so that just "Test_Name" would work.

Anyways, figured I'd leave that here just in case anyone finds this in the future and has a similar issue.

That makes sense - thanks for reporting back! :)

This archived topic is closed to new replies.