Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi LynneLiL – I don’t see any reason why it wouldn’t work if you just slide the right attribute (i.e. category) in the second line;

    $recentposts = new WP_Query(‘showposts=3&offset=1’);

    I don’t know how you call a specific category using WordPress, but if someone can tell you that, it should just fit into the above script. Worth a try at least!

    Thread Starter neilcauldwell

    (@neilcauldwell)

    I’m still struggling with getting the ‘Recent Posts’ Loop to pull up the respective Post Image when each Recent Post isn’t being displayed in the first Loop. For example, let’s say I have one post in the Loop, Post 3, and I have three posts in the ‘Recent Posts’ Loop, Post 1, Post 2, and Post 3 again.

    Post 3 will show its Post Image in both the Loop and in the Recent Posts Loop – but Post 1 and Post 2 won’t show their Post Images in the Recent Posts Loop, because they aren’t being called in the first Loop. And, if I was to click on Post 1 to bring it up in the first Loop, Post 3 would no longer show its’ Post Image in the Recent Posts Loop, because it isn’t being called in the first Loop!

    My site is DotNeil.com – but it’s a new site, so I only have one post with a Post Image, so I don’t think you’ll be able to replicate the problem on this site until I’ve made some more posts with images.

    Hi darintenb – I’ve been having a similar problem with calling ‘Recent Posts’, with certain attributes (excerpts, images), outside of the Loop. I found that if I wanted to call up some recent posts, each with an excerpt, I had to call them in a second Loop, rather than just using a query – otherwise the main Loop on the page would replace the post excerpts with that of the post from within the main Loop. So calling a second ‘recent posts’ Loop fixed my problem (you could pull out and put in any post attributes that you wish to call);

    <?php
    					$recentposts = new WP_Query('showposts=3&offset=1');
    					if($recentposts->have_posts()) : while($recentposts->have_posts()) : $recentposts->the_post(); ?>
    
    					<div class="post" id="post-<?php the_ID(); ?>">
    						<div class="posttitle">
    				 			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    							<p class="meta">
    								<?php the_time('F'); ?> <?php the_time('jS Y'); ?> under <?php the_category(' &amp; ') ?> <?php edit_post_link(); ?></p>
    						</div>
    						<div class="postcontent">
    							<?php the_excerpt(); ?>
    						</div>
    						<div class="postfeedback">
    							<?php wp_link_pages(); ?>
    							<?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)', 'commentlink', ''); ?>
    						</div>
    					</div>
    
    					<?php endwhile; endif; ?>

    Using the above method of calling the ‘Recent Posts’ might work in combination with the ‘Categories’ syntax that you are trying to use, because it appears as though some post attributes are only called properly when they are called from within the Loop – otherwise anything the Loop does will just override what happens in simple queries to the database.

    Hope that helps in some way. I’m still trying to work out a problem with using the ‘Post Images’ script in combination with this Loop – the guff plugin doesn’t seem to pull up the image that is tied to each post *unless* the post is also being displayed on the same page in the first Loop, i.e. reading a post, on it’s permalink URL, will show the ‘post image’ in the Loop *and* in the Recent Posts Loop (if the post in question is in fact a recent post), but if the post isn’t in the first Loop, but *is* in the recent posts Loop, then the image won’t show next to the post in the recent posts Loop…..confusing huh!

    Thread Starter neilcauldwell

    (@neilcauldwell)

    Thanks xinfo – I just tried that and, although it pulls out the posts as expected, it still has the same problem with the images not being posted in the imgposts *unless* the post is also pulled up in the Loop. I presume that this is because the Wp_Query function doesn’t pull up a certain attribute which the Loop does. It also has the unwanted function, whereby clicking on a ‘Continue Reading’ link from a post in the Loop will also extend ALL the posts pulled up in the imgposts script.

    Here is the code that I was using;

    <?php
    					$imgposts = new WP_Query('showposts=3');
    					if($imgposts->have_posts()) : while($imgposts->have_posts()) : $imgposts->the_post(); ?>
    
    					<div class="post clearfix" id="post-<?php the_ID(); ?>">
    						<div class="posttitle">
    							<a href="<?php the_permalink(); ?>"><img class="postimage" src="<?php post_image('shared/images/post_default.jpg', false, false); ?>" width="48" height="48" /></a>
    				 			<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    							<p class="meta">
    								<?php the_time('F'); ?> <?php the_time('jS Y'); ?> under <?php the_category(' &amp; ') ?> <?php edit_post_link(); ?></p>
    						</div>
    						<div class="postcontent">
    							<?php the_content(__('continue reading...')); ?>
    						</div>
    						<div class="postfeedback">
    							<?php wp_link_pages(); ?>
    							<?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)', 'commentlink', ''); ?>
    						</div>
    					</div>
    
    					<?php endwhile; endif; ?>
    Thread Starter neilcauldwell

    (@neilcauldwell)

    I still haven’t had much luck with this one, so any help is very much appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)