Support » Fixing WordPress » Problems with custom fields

  • Resolved jpomfret


    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 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); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • 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(); ?>

    That is exactly what I needed, works perfect now!

    Thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problems with custom fields’ is closed to new replies.