Forums

[resolved] Two loops, same code (almost) different generated markup (the_excerpt()) (1 post)

  1. Rab
    Member
    Posted 1 year ago #

    Hi folks,

    I'm experiencing something very odd with the_excerpt().

    If you look here http://mindfulmum.mumdadbabygroup.co.uk/ you'll see that I've got a few different loops below the main featured image (still working on that).

    The code used to generate the pocket guides section is virtually the same as that of the product recalls section, and yet the excerpt isn't behaving the same.

    Here's the pocket guide code:

    <?php $pocketGuides = new WP_Query('post_type=pocket-guides&posts_per_page=2&order=ASC'); while($pocketGuides->have_posts()) : $pocketGuides->the_post(); ?>
    <div class="article-list-panel">
    	<div class="article-photo-thumbnail"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php if(has_post_thumbnail()) {the_post_thumbnail( 'thumbnail' );} else { ?><img src="<?php bloginfo('stylesheet_directory'); ?>/files/gfx/icons/guide.png" alt="<?php the_title(); ?>" /><?php } ?></a></div>
    	<div class="article-detail">
    		<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    			<p><?php the_excerpt(); ?></p>
    			<p><a href="<?php the_permalink(); ?>">Continue reading...</a></p>
    	</div><br class="clear" />
    </div>
    <?php endwhile; ?>

    Here's the product recall code:

    <?php $productRecalls = new WP_Query('post_type=product-recalls&posts_per_page=2&order=ASC'); while($productRecalls->have_posts()) : $productRecalls->the_post(); ?>
    <div class="article-list-panel">
    	<div class="article-photo-thumbnail"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php if(has_post_thumbnail()) {the_post_thumbnail( 'thumbnail' );} else { ?><img src="<?php bloginfo('stylesheet_directory'); ?>/files/gfx/icons/recall.png" alt="<?php the_title(); ?>" /><?php } ?></a></div>
    	<div class="article-detail">
    		<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    			<p><?php the_excerpt(); ?></p>
    			<p><a href="<?php the_permalink(); ?>">Continue reading...</a></p>
    	</div><br class="clear" />
    </div>
    <?php endwhile; ?>

    Here's the code I used to remove the hook from twentyten's functions.php and replace it with my own:

    add_action( 'after_setup_theme', 'my_child_theme_setup' );
    function my_child_theme_setup() {
    	remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
    	function mindfulmum_auto_excerpt_more( $more ) {return '&hellip;';}
    	add_filter( 'excerpt_more', 'mindfulmum_auto_excerpt_more' );
    }

    I just can't get my head around why the recalls section is using twentyten's original code when i've removed the hook for it and replaced it with my own.

    Any ideas?

    Cheers,
    Robert

Topic Closed

This topic has been closed to new replies.

About this Topic