Get custom meta to display within post

I want to add custom meta I’ve created to show/use in my post or child theme. Which or what variable/function do I need to use?

Would I use something like get_custom_meta(); or something along those lines?

Hi There,

You should copy this file to the child theme(in the same directory path): x/framework/views/global/content.php

After that you can try with this function:

get_post_meta( get_the_ID(), 'your_post_meta' );

Hope it helps :slight_smile:

@thai Thanks, will give that a try.

Sure, let us know how it goes. :slight_smile:

Added the reference code, did not work. Realized I did not need to add to the child theme. However, the code returned nothing.

<?php get_post_meta( get_the_ID(), 'my_post_meta' ); ?>

Hi,

Please change your code to this.


<?php echo get_post_meta( get_the_ID(), 'my_post_meta' ); ?>

Hope that helps

@paul.r the echo helped, but it’s still not returning the correct value. It’s currently displaying ARRAY. Custom meta created using Essential Grid Custom Settings.

Hi,

Please change to

   <?php echo get_post_meta( get_the_ID(), 'my_post_meta', true ); ?>

By adding true, it will get single data instead of array.

This is more of a wordpress question rather than the theme.

For more information kindly refer to the links below

https://developer.wordpress.org/reference/functions/get_post_meta/
https://www.themepunch.com/essgrid-doc/custom-meta-data/

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.