How to display Custom Meta Field Key and Value when using array
-
What would syntax look like when aiming to echo $variable with array containing multiple $var# = get_post_meta( get_the_ID(), ‘var#’, true). Currently I am able to echo array $var#, however after much research and testing if get_post_custom_keys(), get_post_meta(), and other similar functions I am confused about how to display $var# key.
Below is code snippet of what is currently producing partially intended results.
if ( have_posts() ) : while ( have_posts() ) : the_post(); $special_category_slug = get_post_special_category_slug(); $cpmf = array( $var1 = get_post_meta( get_the_ID(), 'var1', true), $var2 = get_post_meta( get_the_ID(), 'var2', true), ); if( ! empty( $cpmf ) ) { echo '<h3>VAR1:</h3>' . $var1; echo '<h3>VAR2:</h3>' . $var2; }
echo is accurately displaying $var# custom meta field value, how can the custom meta field key be displayed only when there is a value associated with key?
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘How to display Custom Meta Field Key and Value when using array’ is closed to new replies.