Support » Fixing WordPress » Call a custom field in the loop

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yes, i have already read it, but i don’t understand 🙁

    this is my loop:

    <?php $my_query = new WP_Query('cat=6&showposts=8'); ?>
    <ul class="friendgallerieslist">
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <img src="/wp-content/themes/tb/images/img.gif"> <a href="<?php the_permalink() ?>" rel="bookmark" target="_blank"><?php the_title(); ?></a>
    <?php endwhile; ?>

    i would call the custom link near the title of my post…what i do now ?

    Stick this somewhere in there and see if it grabs the link you’re seeking:

    <?php get_post_custom_values('syndication_permalink'); ?>

    Schulte i ahve tried your tricks but it doesn’t work….i have solved with this:

    <?php echo post_custom(‘syndication_permalink’); ?>

    Is it possible use a conditional tag for see if the custom field exist ?

    Didn’t know about post_custom. Learn something everyday…I don’t think it’s in the Codex…ouch.

    I don’t see why you couldn’t check for the presence of the field or at the very least the field length…

    is_post_custom would be cool…

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Here you go.

    $custom = get_post_custom_values('syndication_permalink');
    if (count($custom) != 0)
    // do your thing
    echo $custom[0];
    // maybe do more things

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Call a custom field in the loop’ is closed to new replies.