• Hi Everyone

    I’ve been hacking away at this issue for a while now, and I just can’t get the solution.

    I want a ‘Recent Posts’ script that works in combination with the guff Post Image plugin. I’ve tried using the code below, but each ‘recent post’ only seems to show its’ relevant image (as specified by the Post Image plugin) when the same post is shown within the Loop on the same page;

    <ul>
    				<li><h3>Recent Posts</h3></li>
    				<?php
    						               $postslist = get_posts('numberposts=3&offset=1&order=DESC&orderby=post_date');
    						               foreach ($postslist as $post) {
    						      ?>
    						            <ul><li class="recent_post" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>"><img class="postimage" src="<?php post_image('shared/images/post/post_default.jpg', false, false); ?>" width="48" height="48" /></a></a><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3><p class="meta"><?php the_time('F'); ?> <?php the_time('jS Y'); ?> under <?php the_category(' &amp; ') ?> <?php edit_post_link(); ?>
    </li></ul>
    						            <?php }; ?>
    			</ul>

    So, that means that unless a post is pulled up within the Loop on the same page, the same post, when shown in the ‘Recent Posts’ script, won’t show its’ own image – it will just show the default Post Image icon which I have specified.

    Obviously there is some kind of attribute that is unique to each post and is pulled-up when a post is called within the Loop. The ‘Recent Posts’ script (shown above) doesn’t seem to call this attribute (whatever that may be) – so I’m under the impression that this Recent Posts script isn’t a ‘ proper Loop’ as such.

    I’ve also tried calling the Loop, as suggested by the moderator further down in the this thread, https://www.ads-software.com/support/topic/63004?replies=8, but I can’t get the loop to work within the provided imgposts script – it won’t display anything.

    Is there a way of calling the Loop, so that it only shows the last 3 posts, with an offset of 1, and so that it formats the posts in a similar way to the script I’ve posted above (inc. the post image) ?

    Any help is very much appreciated! I’m going crazy over this one!

Viewing 5 replies - 1 through 5 (of 5 total)
  • even i face the same problem

    well solution

    IMPORTANT :old upload images won’t work which is uploaded before you activate the plugin .
    your new images will work fine .

    if you want to follow the above forum link code which you posted there is small change you have to do in the code

    line 3

    you have change

    from

    while($imgposts->haveposts()) :

    to

    while($imgposts->have_posts()) :

    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’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.

    Did you ever figure this out?
    If so… what did you do?

    Figured it out!
    Give up on the “post_image” plug-in for this and simply do what’s talked about in this post!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Recent Posts & Image plugin or script (help needed!)’ is closed to new replies.