I create custom field type select
Need display values
from custom field outside <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
like bootstrap tabs.
Code 1:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
var_dump($postid);
echo get_post_meta($postid, 'employee_category', true);
wp_reset_query();
?>
return - int(269)
- id page.
Code 2:
<?php
$value = get_field( "employee_category" );
if( $value ) {
echo $value;
} else {
echo 'empty';
}
?>
return - empty
.
Code 2 inside loop work correctly.
How display values outside loop?
UPD
Need to display all categorys.
This code
<?php
global $wp_query;
$postid = $wp_query->post->ID;
$value = get_field( "employee_category", 269 );
var_dump($value);
if( $value ) {
echo $value;
} else {
echo 'empty';
}
wp_reset_query();
?>
return null
global $post
on the top of your code, and get the$post->ID
. That should work for you. If don't please elaborate your question.