• Resolved digiman999

    (@digiman999)


    Hello,

    I’m wanting to display a custom field but only on posts in a specific caterogy (Releases, which is the parent category). I’ve put together the following, and tried it on both my themes single.php & index.php files. At present, the data is displaying on all posts/all categories. Any ideas why, does this code look okay?

    <?php
    $values = get_post_custom_values("iTunes");
    {
    if(!empty($values));
    if (in_category('releases'));
    echo "Available On " . "<a target=_blank href=$values[0]>iTunes</a>" . '<br />' . '<br />';
    } ?>

    PS: iTunes is the name of the custom field, and the text should display as Available On iTunes, with ‘iTunes’ being a link

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php
    $values = get_post_custom_values("iTunes");
    if (!empty($values) && in_category('releases') {
      echo "Available On " . "<a target=_blank href=$values[0]>iTunes</a>" . '<br />' . '<br />';
    }
    ?>
    Thread Starter digiman999

    (@digiman999)

    Doesn’t work I’m afraid, gives:

    Parse error: parse error, unexpected ‘{‘ in /home/edhowell/public_html/wp-content/themes/Defne/index.php on line 30

    oops missed a paren

    <?php
    $values = get_post_custom_values("iTunes");
    if (!empty($values) && in_category('releases')) {
      echo "Available On " . "<a target=_blank href=$values[0]>iTunes</a>" . '<br />' . '<br />';
    }
    ?>
    Thread Starter digiman999

    (@digiman999)

    It works! Many thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category Specific Custom Field Display’ is closed to new replies.