• Resolved kalico

    (@kalico)


    I have a piece of code that isn’t working and I can’t figure out what is wrong with it. (some of my code is being truncated, by the forum, but hopefully the important stuff is showing up)….

    <?php foreach($results as $cat){ ?>
    <h3 ><a href="<?php echo get_category_link($cat->cat_ID); ?>">
    <?php echo $cat->cat_name; ?></a></h3>
    
        <select name="category" style="font-family: arial,verdana, sans-serif;font-size:9pt" onchange="MM_jumpMenu('parent',this,0)">
        <option value="">Sermon Series on <?php echo $cat->cat_name; ?></option>
    <?php query_posts('category_name='. $cat->cat_name . '&showposts=-1&order=ASC'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <option value="<?php the_permalink(); ?>">
    <?php the_title(); ?>
    <?php get_post_custom_values('Subtitle'); ?>
    </option>
    <?php endwhile; ?>
    </select>

    This works for the most part, displaying a drop-down list of posts in the category. I am trying to add a custom field value, so that the list shows titles AND subtitles. But the code for subtitle is not working, and I can’t see the mistake.

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

    This works elsewhere just fine, but in this drop down list, I only get the word “Array” in it’s place. I hope someone who hasn’t grown code-blind over this can help me. I am probably missing something obvious.

    Thanks in advance. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • David Yeiser

    (@davedotcom)

    Well, one thing I noticed is there’s an extra space in your first <h3> tag.

    And try removing the echo out of the PHP statement after the H3 tag.

    OLD:
    <?php echo get_category_link($cat->cat_ID); ?>

    NEW:
    <?php get_category_link($cat->cat_ID); ?>

    Thread Starter kalico

    (@kalico)

    Wow, I forgot I even posted this. The problem was in the Subtitle call. The resolution was to change it like this:

    <?php echo post_custom('Subtitle'); ?>

    I don’t know how I found the answer, but thanks much to davedotcom for trying to help me out! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field code — what is wrong with this?’ is closed to new replies.