Wordpress condition if ... else statement for wp_pagenavi plugin
Published March 24th, 2008 in Scripts, Tips and Tricks, WordpressI wanted to create a condition in a theme, where if the plugin wp_pagenavi existed then use the plugin. If the plugin does not exist, then use the text Next and Previous. Researching through the internet took quite some time and without a functioning code. I found this code in another Wordpress theme and applied it to another and it worked great. The code below was applied to the footer.php file and any existing remnant of the original code was removed from the index.php page.
<div class="post_nav">
<?php if(function_exists('wp_pagenavi')): ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<?php posts_nav_link(); ?>
<?php endif; ?></p>
</div>
I also appended the following to the style.css. It wasn't really necessary to get the code operational, but did make things a little smoother. This code was also taken from a theme or two.
.post_nav {
float: left;
width: 620px;
padding-left: 10px;
}
.post_nav a:link, .post_nav a:visited {
color: #006699;
text-decoration: none;
}
.post_nav a:hover, .post_nav a:active {
color: #006699;
text-decoration: underline;
Print This Post
Email This Post
Related Articles
- WordPress 2.9 Add Post Image
- How to get wp-print to display Nextgen nicely!
- The purpose of the wp_head code in Wordpress
- Wordpress 2.6 Revision Control
- Wordpress Plugin: Paypal Donate (Version 1.1)

(2 votes, average: 4.50 out of 5)