Archive

Posts Tagged ‘pagenavi’

$ The use of pagenavi plugin $

August 9th, 2008 No comments

After the activation and installation of pagenavi, there is a need to modify the files of index.php and categary.php, and this is a little difficult to the blogger.

Take a index.php in a theme for example,

The original file is:

<?php get_header(); ?>
<div id=”container”>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2 class=”title_link”><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”>
<?php the_title(); ?>
</a></h2>
<div class=”smallfont”><?php the_time(’F jS, Y’) ?> <?php _e(’by’); ?> <?php the_author(); ?></div>
<div class=”entry”>
<?php the_content(); ?>
<div class=”postmetadata”>
<div class=”ipost_tag”>Filed under :
<?php the_category(’, ‘) ?>
</div>
<div class=”ipost_comment”><img src=”<?php bloginfo(’stylesheet_directory’); ?>/images/comment.gif” width=”16″ height=”16″ alt=”tag” align=”top” />
<?php comments_popup_link(’0 Comment &#187;’, ‘1 Comment &#187;’, ‘% Comments &#187;’); ?>
<?php edit_post_link(’Edit’, ‘ &#124; ‘, ”); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<div class=”navigation”>
<div id=”nav_left”>
<?php posts_nav_link(’ ‘, ‘&laquo; Previous Page’, ”); ?>
</div>
<div id=”nav_right”>
<?php posts_nav_link(’ ‘, ”, ‘Next Page &raquo;’); ?>
</div>
</div>
<?php else : ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2>
<?php _e(”Not Found”); ?>
</h2>
</div>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

The following are the modified codes,please pay attention to the uderlined lines in the section of <div class=”navigation”>:

<?php get_header(); ?>
<div id=”container”>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2 class=”title_link”><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”>
<?php the_title(); ?>
</a></h2>
<div class=”smallfont”><?php the_time(’F jS, Y’) ?> <?php _e(’by’); ?> <?php the_author(); ?></div>
<div class=”entry”>
<?php
if (is_single()) {
the_content();
}
else {//no content, nothing.
}
?>
<div class=”postmetadata”>
<div class=”ipost_tag”>Filed under :
<?php the_category(’, ‘) ?>
</div>
<div class=”ipost_comment”><img src=”<?php bloginfo(’stylesheet_directory’); ?>/images/comment.gif” width=”16″ height=”16″ alt=”tag” align=”top” />
<?php comments_popup_link(’0 Comment &#187;’, ‘1 Comment &#187;’, ‘% Comments &#187;’); ?>
<?php edit_post_link(’Edit’, ‘ &#124; ‘, ”); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<div class=”navigation”>

<?php if(function_exists(’wp_pagenavi’)) : ?>
<?php wp_pagenavi() ?>
<?php else : ?>
<div id=”nav_left”>
<?php posts_nav_link(’ ‘, ‘&laquo; Previous Page’, ”); ?>
</div>
<div id=”nav_right”>
<?php posts_nav_link(’ ‘, ”, ‘Next Page &raquo;’); ?>

</div>

<?php endif; ?>
</div>

<?php else : ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2>
<?php _e(”Not Found”); ?>
</h2>
</div>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

Related Blogs

Categories: wordpress Tags: ,