views:

51

answers:

1

This worked perfectly in a previous version of wordpress, different site tho. I have a custom field called flash on several wp pages but it keeps defaulting to "printed if results are empty". Any ideas on why this wouldn't work?

<?php 
if ( function_exists('get_post_custom_values') ) 
  {    
   $mykey_values = get_post_custom_values('flash');
   if(count($mykey_values) > 0)
    {

foreach ( $mykey_values as $key => $value ) 
 { 
  echo "$value";


 }
    }
   else
    {
     //printed if results are empty
   echo("mainPage.swf");
    } 

  } 
 else
  {
   //printed if function doesn't exist
   echo("mainPage.swf");
  }
?>
A: 

Hi not really sure why that is not working (as long as you are sure you do have custom fields with 'flash' values in the post). Anyhow, try the following, I am sure the following will work.

<?php
  $custom_fields = get_post_custom();
  $my_custom_field = $custom_fields['flash'];
  foreach ( $my_custom_field as $key => $value )
    echo $key . " => " . $value . "<br />";
?>
Fraser