Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] Blog post loop issue Re: [Solved] Blog post loop issue

#80269
Templar
Member

Man, I have the Same problem here and won’t create a different post, so…

Offline everything works fine, but when I put the files online the <?php the_title(); ?> function gets the title of the Page, not the Posts like the following image: http://yfrog.com/5b99994592j

As you can see, there’s a featured post (last post) and I’d like to put the older posts below that one. I could increase the number of featured posts on the wp_query – show posts, but this way I can’t add the navigation buttons and the page would be gigantic.

The featured post code:

Code:
<div id="block-blog">

<?php
$featured = new WP_Query();
$featured->query(‘showposts=1’);
while($featured->have_posts()) : $featured->the_post();

$wp_query->in_the_loop = true; // This line is added so that the_tags(”) will work outside the regular loop.
$featured_ID = $post->ID; // We’ll store this here so that we know to skip this post in the main loop
?>

<?php if (get_post_meta($post->ID, ‘large_preview’, true)) { ?>
<div class="image_block">
<img src="<?php echo get_post_meta($post->ID, ‘large_preview’, true); ?>" alt="Featured Post" />
</div>
<?php } ?>
<div class="block-blog">

<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small>em: <?php the_time(‘d/m/Y’); ?> onde: <?php the_category(‘, ‘); ?> tags: <?php the_tags(”); ?> por: <?php the_author_posts_link(); ?></small>
<?php the_excerpt();?>
<a href="<?php the_permalink(); ?>" class="button">Leia Mais...</a>

</div>

<?php endwhile; ?>
</div>

The rest of the posts:

Code:
<div class="block-blog">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>

<? if ($post-<ID != $featured_ID) { ?>

<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small>on <?php the_time(‘M d’); ?> in <?php the_category(‘, ‘); ?> tagged <?php the_tags(”); ?> by <?php the_author_posts_link(); ?></small>
<?php the_content(‘Read More’); ?>
<div class="separator biggap"></div>

<? } ?>

<?php endwhile ?>

<div id="posts_navigation">
<?php previous_posts_link(); ?>
<?php next_posts_link(); ?>
</div>

<?php else : ?>

<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn’t here.</p>
<?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

<?php endif; ?>

</div>

If I could add 10 posts inside the featured and add the navigation (recent – older posts), that would be perfect.

Well, I hope someone can help us, I’m a bit desperate haha.