• Resolved huppellepup

    (@huppellepup)


    Hi everybody,
    I have found a strange problem which gives me problems. Under this text you see a “custom field”, followed by a “recent post” and followed by a “custom field”. Only this time it doesn’t show the “custom field” anymore.
    Any ideas?

    I’m using the “Twenty Twelve” template and you can see the problem on the homepage of: http://tuna.nl

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Hi huppellepup

    Do you display the recent posts with a secondary query (new WP_Query or get_posts())?

    If so, you might need to reset the loop after it.
    https://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/

    Thread Starter huppellepup

    (@huppellepup)

    Hi Keesiemeijer,

    Thanks for your reaction.
    I’m not sure, but this is the code I’ve used:

    <section>
    	<?php $the_query = new WP_Query( 'showposts=3' ); ?>
    	<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
    		<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<div>
    
    				<header>
    					<h4 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h4>
    				</header>
    				<span>
    					<?php the_excerpt(); ?>
    				</span>
    
    			</div>
    		</article><!-- #post -->
    	<?php endwhile;?>
    </section>

    The problem occurs in the following templates: Twenty Twelve, Twenty Thirteen, Twenty Fourteen.

    Thread Starter huppellepup

    (@huppellepup)

    Hi Keesiemeijer,

    Thanks for the link!
    Adding the <?php wp_reset_postdata(); ?> to the code solved this problem.

    Thread Starter huppellepup

    (@huppellepup)

    Yes!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom field not working when placed after “Recent Posts”’ is closed to new replies.