Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. adamwork
    Member

    Hi all

    I have this template page that I've setup, which shows a list of posts from a certain category. At the bottom of the page, I have a "next" link, which should show more posts. However, when you click on the "next" it only displays my header and footer, and no content. any advice?! here is my code:

    <?php /*
    Template Name: news
    */
    ?>

    <?php get_header(); ?>

    <!-- Featured news story area !-->

    <?php if(!is_paged()) { ?>

    <div id="content">
    <div class="post" id="post-<?php the_ID(); ?>">
    <h1>News</h1>

    <div id="newsline">
    <?php query_posts("showposts=1&category_name=Latestnews"); ?>
    <?php while (have_posts()) : the_post(); ?>

    <div class="title">" rel="bookmark" class="title"><?php the_title(); ?></div>

    <div class="meta">[<?php the_time('j M Y') ?> | <?php the_author() ?> | <?php comments_popup_link('No Comment', '1 Comment', '% Comments');?>]</div>

    <?php $values = get_post_custom_values("Latestnews");?>

    <?php $values = get_post_custom_values("Image");
    if (isset($values[0])) { ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=620&h=340&zc=1&q=587"
    alt="<?php the_title(); ?>" width="620px" height="360px" />

    <?php } ?>
    <div class="info"><?php the_excerpt_reloaded(100, '', 'none', TRUE, 'Read more >>', FALSE, 2); ?>
    <?php endwhile; ?>
    </div>
    </div>
    </div>
    <!-- End of Featured news story area !-->

    <!-- Start list of other news items !-->

    <div id="front-list">

    <h2>Other news</h2>
    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=3&paged=$page&posts_per_page=5"); ?>

    <?php while (have_posts()) : the_post(); ?>

    <div class="clearfloat">

    <h3 class=cat_title><?php the_category(', '); ?> &raquo</h3>
    <div class="title">" rel="bookmark"><?php the_title(); ?></div>
    <div class="meta">[<?php the_time('j M Y') ?> | <?php the_author() ?> | <?php comments_popup_link('No Comment', '1 Comment', '% Comments');?>]</div>

    <!-- generates thumbnail image -->

    <div class="spoiler">
    <?php $values = get_post_custom_values("Image");
    if (isset($values[0])) { ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=80&h=80&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="80px" height="80px" />

    <?php } ?>

    <div class="info"><?php the_excerpt_reloaded(50, '', 'none', TRUE, 'Read more >>', FALSE, 2); ?></div>
    </div>

    </div>

    <?php endwhile; ?>

    <div class="navigation">
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    else { ?>

    <div class="right"><?php next_posts_link('Next Page »') ?></div>
    <div class="left"><?php previous_posts_link('« Previous Page') ?></div>
    <?php } ?>

    </div>

    </div>

    </div>

    <div id="toppage-right">
    <h2>Latest blogs</h2>

    <?php query_posts("showposts=4&category_name=Sales-rep"); $i = 1; ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfix">
    <div class="post">
    <div class="h2">" rel="bookmark" class="title"><?php the_title(); ?></div>
    <div class="meta">[<?php the_time('j M Y') ?> | <?php the_author_firstname(); ?> <?php the_author_lastname(); ?>]</div>

    <?php $values = get_post_custom_values("Image");
    if (isset($values[0])) { ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=120&h=120&zc=1&q=120"
    alt="<?php the_title(); ?>" width="120px" height="100px" />

    <?php } ?>

    <p><?php the_excerpt_reloaded(18, '', 'none', TRUE, 'Read more >>', FALSE, 2); ?></p>
    </div>
    <?php endwhile; ?>
    </div>

    </div>
    </div>
    </div>
    </div>
     
    <?php get_sidebar(); ?>

    <?php } ?>

    <?php get_footer(); ?>

    Thanks in advance

    Posted 1 year ago #
  2. on top of your template you have

    <?php get_header(); ?>
    
    <!-- Featured news story area !-->
    
    <?php if(!is_paged()) { ?>
    ...
    ...

    means after the header is displayed only stuff will show if it's NOT paged "if(!is_paged()"

    The end of this "if(!is_paged()" condition is after here just after sidebar and before footer:

    <?php get_sidebar(); ?>
    
    <?php } ?>
    
    <?php get_footer(); ?>

    everything between <?php if(!is_paged()) { ?> and <?php } ?> will show only on first (unpaged) view.
    move <?php } ?> up under "End of Featured news story area" to show what follows...

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Join us! or log in (lost password?):