WordPress.org

Support

Support » How-To and Troubleshooting » Call a custom field in the loop

Call a custom field in the loop

Viewing 6 replies - 1 through 6 (of 6 total)
  • Marcomail
    Participant

    @marcomail

    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(); ?>
    <li>
    <img src="/wp-content/themes/tb/images/img.gif"> <a href="<?php the_permalink() ?>" rel="bookmark" target="_blank"><?php the_title(); ?></a>
    </li>
    <?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'); ?>

    Marcomail
    Participant

    @marcomail

    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…

    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.