wordpress - get_post_meta and if statement

Discussion in 'PHP' started by Farhad, Mar 12, 2010.

  1. #1
    Hello everyone,

    I am having trouble with using get_post_meta inside an if/else or switch statement. I don't know what I am doing wrong.

    I am using this:
    $vCategory = get_post_meta($post->ID, "videocategory", true)):
    Code (markup):
    When I print the $vCategory I get exactly what I wanted, lets say for example "Test".

    However when I put $vCategory in a if statement like:

    if($vCategory == "Test"){
    echo "it works!";
    }else{
    echo "doesn't work";
    }
    Code (markup):
    I get the output doesn't work every single time. When I look to the variable $vCategory inside the if statement its still "Test" but when I say if ($variable == "Test") it just doesn't work somehow.

    Anyone knows what I can do about this?
     
    Farhad, Mar 12, 2010 IP