WordPress.org

Ready to get started?Download WordPress

Forums

Simply Exclude
Excluding Categories on Front Page Causes Conflict with Numbered Page Navigation (1 post)

  1. Mike Shupp
    Member
    Posted 12 months ago #

    WP 3.5.1
    Thesis Theme 1.8.5
    Simply Exclude 2.0.6

    I'm using the plug-in to exclude some categories from the front page; however, it seems to be conflicting with the navigation code I'm using, which I have posted here below, such that: the numbered page navigation does not appear on the front page, or on /page/2/, /page/3/, etc... (however it is working on other archive pages like categories, date, search, tags))

    What is the solution?

    function numbered_page_nav($prelabel = '', $nxtlabel = '', $pages_to_show = 8, $always_show = false) {
    	global $request, $posts_per_page, $wpdb, $paged;
    
    	$custom_range = round($pages_to_show/2);
    	if (!is_single()) {
    		if(!is_category() && !is_tag()) {
    			preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
    		}
    		else {
    			preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
    		}
    		$blog_post_count = $matches[1];
    		$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $blog_post_count");
    		$max_page = ceil($numposts /$posts_per_page);
    		if(empty($paged)) {
    			$paged = 1;
    		}
    		if($max_page > 1 || $always_show) {
    			echo "<div class='page-nav'><div class='page-nav-intro'>Page $paged of $max_page</div>";
    			if ($paged >= ($pages_to_show-2)) {
    				echo '<div class="page-number"><a href="'.get_pagenum_link().'">1</a></div><div class="elipses">...</div>';
    			}
    			for($i = $paged - $custom_range; $i <= $paged + $custom_range; $i++) {
    				if ($i >= 1 && $i <= $max_page) {
    					if($i == $paged) {
    						echo "<div class='current-page-number'>$i</div>";
    					}
    					else {
    						echo '<div class="page-number"><a href="'.get_pagenum_link($i).'">'.$i.'</a></div>';
    					}
    				}
    			}
    			if (($paged+$custom_range) < ($max_page)) {
    				echo '<div class="elipses">...</div><div class="page-number"><a href="'.get_pagenum_link($max_page).'">'.$max_page.'</a></div>';
    			}
    			echo "</div>";
    		}
    	}
    }
    remove_action('thesis_hook_after_content', 'thesis_post_navigation');
    add_action('thesis_hook_after_content', 'numbered_page_nav');

    http://wordpress.org/extend/plugins/simply-exclude/

Reply

You must log in to post.

About this Plugin

About this Topic