WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problems with custom fields (3 posts)

  1. jpomfret
    Member
    Posted 3 years ago #

    In my theme I have a scroller which displays 2 static stories and pulls in the last blog post from a particular category. That works fine.

    I also have 4 custom fields that are displayed in divs on the same page. This works fine also, without the scroller on the page.

    It's like the two scripts interfere with each other, I feel like its a simple syntax mistake but I have stared at it for too long and can't see it. Thanks much for your help!

    <div class="feature" id="3" style="display:none;">
    	<img src="/wp-content/themes/TwoTurtles/imgs/coralFeature.jpg" alt="Coral"/>
    
    	<?php $index = new WP_query('cat=3&showposts=1');
    	if($index->have_posts()) : while ($index->have_posts()) : $index->the_post(); ?>
    	<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    	<small>Published on <?php the_time('F d, y'); ?></small>
    	<?php the_excerpt(); ?>
    	<?php endwhile; endif; ?>
    </div>
    
    <div class="inner tl">
    	<h2><a href="/?page_id=22">Freshwater Fish</a></h2>
    	<img src="/wp-content/themes/TwoTurtles/imgs/guppy-Google100.jpg" alt="fish"/>
    	<p><?php echo get_post_meta($post->ID, 'freshwater', true); ?>
    	</p>
    </div>
  2. vtxyzzy
    Member
    Posted 3 years ago #

    I think your slider is stepping on $post (the_post()). Try resetting the query like this:

    <?php the_excerpt(); ?>
    	<?php endwhile; endif; ?>
    	<?php wp_reset_query(); ?>
    </div>
  3. jpomfret
    Member
    Posted 3 years ago #

    That is exactly what I needed, works perfect now!

    Thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Topic