Forum Moderators: coopster

Message Too Old, No Replies

How to add navigation to Tags pages for wordpress

Helping to edit something at a Navigation function in a wordpress theme ,

         

ElMobd3

9:54 am on Dec 25, 2010 (gmt 0)

10+ Year Member



Hi everyone, I have been installing a Wordpress Theme, the theme has a custom navigation function. It shows a page navigation at archive pages, categories pages but doesn't show at tags pages.

This is the function from functions.php

<?php function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
global $request, $posts_per_page, $wpdb, $paged;
if(empty($prelabel)) { $prelabel = '<strong>&laquo;</strong>';
} if(empty($nxtlabel)) {
$nxtlabel = '<strong>&raquo;</strong>';
} $half_pages_to_show = round($pages_to_show/2);
if (!is_single()) {
if(!is_category()) {
preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); }
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
$max_page = ceil($numposts /$posts_per_page);
if(empty($paged)) {
$paged = 1;
}
if($max_page > 1 || $always_show) {
echo "$before <div class='Nav'><span>Pages ($max_page): </span>"; if ($paged >= ($pages_to_show-1)) {
echo '<a href="'.get_pagenum_link().'">&laquo; First</a> ... '; }
previous_posts_link($prelabel);
for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) {
echo "<strong class='on'>$i</strong>";
} else {
echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> '; }
}
}
next_posts_link($nxtlabel, $max_page);
if (($paged+$half_pages_to_show) < ($max_page)) {
echo ' ... <a href="'.get_pagenum_link($max_page).'">Last &raquo;</a>'; }
echo "</div> $after";
}
}
}
?>


and that's the content of archive.php in my theme that show archive, tag and cat for my blog

<?php get_header(); ?>

<div id="content">

<div class="postsbody">

<?php if (have_posts()) : ?>
<div class="latestpart">
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class="pagetitle"><?php single_cat_title(); ?> Videos</h2>
<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
<h2 class="pagetitle"><?php single_tag_title(); ?> Videos</h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class="pagetitle">Author Archive</h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h2 class="pagetitle">Blog Archives</h2>
<?php } ?>
<div class="latestvideos">

<?php while (have_posts()) : the_post(); ?>
<div class="latestvideo">
<div class="latestname">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php $tit = the_title('','',FALSE); echo substr($tit, 0, 20); if (strlen($tit) > 20) echo " ..."; ?></a>
</div>
<div class="latestthumb">
<?php if( get_post_meta($post->ID, "thumb", true) ): ?>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><img src="<?php $values = get_post_custom_values("thumb"); echo $values[0]; ?>" width="120" height="90" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/noimage.gif" width="120" height="90" alt="<?php the_title(); ?>" /></a>
<?php endif; ?>
</div>
<div class="latestinfo">
<div class="postviews">
<?php echo time_ago(); ?>
</div>
<div class="postviews">
<?php if(function_exists('the_views')) { the_views(); } ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="latestvideosb"></div>
</div>
<div class="navigation">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi('', '', '', '', 3, false);} ?>
</div>
<?php else: ?>

<div class="latestpart">
<h2 class="pagetitle">Nothing Found</h2>

<div class="latestvideos">

<div class="entry">
<p>Please, use the category menu or search a term.</p>
</div>

</div>
<div class="latestvideosb"></div>
</div>

<?php endif; ?>

</div>

<?php include (TEMPLATEPATH . '/sidebar_home.php'); ?>

</div>

<?php get_footer(); ?>


I hope anyone help me with that function to show navigation at tags page, thanks.

ElMobd3

7:25 pm on Dec 25, 2010 (gmt 0)

10+ Year Member



This a link for archive
[uimgs.com...]
& this for a category
[uimgs.com...]
and this for a tag
[uimgs.com...]