i have these codes :

foreach ( $ids as $idss ) {
echo  get_post_meta($idss, 'IMDB', true);

i have search box with Form element that search and find all id ( $ids ) of searched word .

i want to print all $ids 's IMDB field ! i can do it on page.PHP of theme ! but i cant do it on header.PHP

i used global $post; and it didnot worked !

Updates ( answer ) : i add this line to my code :

require_once( dirname(__DIR__) . '/wp-load.php');

1 Answer 1


Is your $ids array empty? Echo out each $idss to see if it contains a value.

foreach ( $ids as $idss ) {
  echo $idss . ' <-- ID<br>';
  echo  get_post_meta( $idss, 'IMDB', true );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.