Forums

If problems (2 posts)

  1. almemedia
    Member
    Posted 4 months ago #

    Hi, I am trying to create a if sequense, but I don't have any luck:

    <?php // Works inside of the Loop
    function function_name() {
    global $post;
    $thePostID = $post->ID;
    } ?>
    <?php foreach(get_field('matcher') as $matcher): ?>
    <?php foreach( get_post_meta($matcher->ID, 'vinnare') as $vinnare): ?>
    <?php foreach( get_post_meta($matcher->ID, 'vinnarenamn') as $vinnarenamn): ?>
    <?php foreach( get_post_meta($matcher->ID, 'forlorarenamn') as $forlorarenamn): ?>							
    
    <?php echo $thePostID          /// Just for testing?>
    <?php echo $vinnare ?>
    <?php if ($vinnare == $thePostID) { ?>
    Test
    <?php }?>

    My problem is that the $thePostID don't return any value - so I guess thats why the if statement don't work...
    Can anybody help me?

  2. netcs.vg
    Member
    Posted 4 months ago #

    $thePostID gets assigned a value inside the function function_name(). Your code never calls this function so the assignment is never executed...

Reply

You must log in to post.

About this Topic

Tags