开发者

Wordpress; image not appearing post loop

I have post about this before, but I didn't get any conclusive answer but I'm really hoping someone can help me. I have setup some custom post types, and with them, some custom fields using Wordpress 3's UI.

One of the fields I have set up is called banner_image, but in the loop, it doesn't output the image.

<?php echo get_post_meta($post->ID, 'banner_image', true); ?>

This simply outputs the ID number of the post. If I set the function to false, I get an array with this ID in and nothing else. How do I get the path to the image? I can't work this开发者_运维百科 out and Googling reveals a sea of content not related to my problem, it's a real difficult one to search for so you're my only hope!

Many thanks, Michael.

<?php
global $post;
$tmp_post = $post;
$args = array(

        'post_status' => 'publish',
        'post_type' => 'work',
        'order' => 'DESC'

);

$myposts = get_posts( $args );

foreach( $myposts as $post ) : setup_postdata($post); ?>

    <?php if( get_post_meta($post->ID, 'show_in_home_banner', true) == "yes" ) { ?>

        <li class="slide">

            <div class="slide-image">
                <a href="<?php echo get_page_link($post->ID) ?>">
                    <?php echo get_post_meta($post->ID, 'banner_image', true); ?>
                </a>
            </div>

            <div class="slide-content">
                <h3 class="slide-header"><a href="<?php echo get_page_link($post->ID) ?>"><?php echo get_post_meta($post->ID, 'sub_title', true); ?></a></h3>
                <p class="slide-title"><strong><?php echo the_title(); ?></strong></p>
            </div>

        </li>

    <?php } ?>

<?php endforeach; ?>


Try this

<?php echo get_post_meta($post->ID, 'banner_image', $single); ?>


Apparently, the custom field 'banner_image' doesn't have the right value. I guess it doesn't save the correct value first. You may want to install the Simple WP FirePHP plugin (http://wordpress.org/extend/plugins/simple-wp-firephp/) and check the value with the fb() function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜