Forums

[resolved] custom fields help (3 posts)

  1. goldmember
    Member
    Posted 1 year ago #

    on the post editor page for this post, I added a custom field where
    CUSTOM FIELD NAME= portfolio-image
    CUSTOM FIELD VALUE= http://www.shirtsaboutnothing.com/wordpress/wp-content/uploads/site-elements/test1-sml.jpg

    and on another post, I have similar values:
    CUSTOM FIELD NAME= portfolio-image
    CUSTOM FIELD VALUE= http://www.shirtsaboutnothing.com/wordpress/wp-content/uploads/site-elements/test2-sml.jpg

    Then, in the body of the page editor for this page i have the following code towards the bottom, which I thought would spit out those images that i entered in the posts custom fields.

    <h5>Recent Projects</h5>
            <div id="recent-projects">
    		<?php
                $count = 0;
                $recentblog = new WP_Query();
                $recentblog->query("showposts=3&category_name=Portfolio");
                while($recentblog->have_posts()) : $recentblog->the_post()
            ?>
            <?php
            if($count==0) {
                    $count++;
            ?>
            <div class="frontpage-project-box-1">
                    <a href="<?php the_permalink(); ?>"><img src="<?php $thumb = get_post_custom_values('portfolio-image'); echo $thumb[0]; ?>" alt="<?php the_title(); ?>" />
                    <h4><?php the_title(); ?></h4></a>
                </div>
            <?php
                } else {
            ?>
            <div class="frontpage-project-box">
                    <a href="<?php the_permalink(); ?>"><img src="<?php $thumb = get_post_custom_values('portfolio-image'); echo $thumb[0]; ?>" alt="<?php the_title(); ?>" />
                    <h4><?php the_title(); ?></h4></a>
                </div>
            <?php
                }
                endwhile;
            ?>
        	</div><!--end recent-projects-->

    but for some reason, as you can see, it is not spitting out the images on this page. I'm using the exec-php plugin so putting php code in my page editor should work.

    please advise what's wrong. thanks!

  2. vtxyzzy
    Member
    Posted 1 year ago #

    From what I can see, I think that your query for category_name=Portfolio is not finding any posts. Your code is being executed because the div with id='recent-projects' is being created.

  3. goldmember
    Member
    Posted 1 year ago #

    oh. duh. thank you!!!

Topic Closed

This topic has been closed to new replies.

About this Topic