[SOLVED] Hide next/previous navigation bar if there is just one post in a category...
Hy,
on sigle post pages I restricted the next/previous navigation to show only posts from the same category. http://forum.bytesforall.com/showthread.php?t=4914 Is there any solution to hide navigation bar, if there is just one post in the category? Thanks... |
The problem is that a single post page is a single post page weither you get to it via it's category, recent post link or from the blog page. So there is no way to tell if you should use the navagation or not.
|
:( Thank You, Juggledad, I understand....
And in a different way? It's possible "say to the navigation bar": if there is no content to show, don't display? I mean my setting is not to show home link in navigation bar, so if a category has one post, in the navigation bar there is no content... |
the nav bars wont show unless you have more than one post in a category
|
Juggledad: Could You please have a look at this:
http://elcamino.joljarok.hu/repulo-v...ni-a-caminora/ (Category: Utazás) this is an example for one post in category on my page. And nav bar is empty... but there is. The code for navigation on single post pages: /* Next/Previous POST Links (on single post pages) in next_post_link "next" means newer posts Available parameters for $location: Top, Middle, Bottom. Default: Top */ function bfa_next_previous_post_links($location = "Top") { global $bfa_ata; if ( is_single() AND strpos($bfa_ata['location_single_next_prev'],$location) !== FALSE AND // don't display on WP Email pages intval(get_query_var('email')) != 1 ) { echo '<div class="navigation-'.strtolower($location).'"> <div class="older' . ($bfa_ata['home_single_next_prev'] != '' ? '-home' : '') . '">'; $bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ? previous_post_link('%link »', '%title', TRUE) : next_post_link('« %link', '%title', TRUE); echo ' </div>' . ($bfa_ata['home_single_next_prev'] != '' ? '<div class="home"><a href="' . $bfa_ata['get_option_home'] . '/">' . $bfa_ata['home_single_next_prev'] . '</a></div>' : '') . '<div class="newer' . ($bfa_ata['home_single_next_prev'] != '' ? '-home' : '') . '"> '; $bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ? next_post_link('« %link', '%title', TRUE) : previous_post_link('%link »', '%title', TRUE); echo '</div><div class="clearboth"></div></div>'; } } |
oops, your right I had mine at the bottom of the page so I didn't see the space there.
edit bfa_next_previous_links.php and find line 79 (version 3.4.6) and change it from HTML Code:
if ( !is_single() AND !is_page() AND HTML Code:
if ( !is_single() AND !is_page() AND !is_category() AND ------------------- update: this won't work eithor, it shuts of nav for all category pages. There is nothing to distinguish a category page that has onel one post vers one that has multiple posts. |
Thanks Juggledad...
I found the solution (red=inserts): /* Next/Previous POST Links (on single post pages) in next_post_link "next" means newer posts Available parameters for $location: Top, Middle, Bottom. Default: Top */ function bfa_next_previous_post_links($location = "Top") { global $bfa_ata; if ( is_single() AND strpos($bfa_ata['location_single_next_prev'],$location) !== FALSE AND // don't display on WP Email pages intval(get_query_var('email')) != 1 ) { foreach((get_the_category()) as $category) { $catcount =$category->category_count; //echo $catcount; } if ($catcount > 1) { echo '<div class="navigation-'.strtolower($location).'"> <div class="older' . ($bfa_ata['home_single_next_prev'] != '' ? '-home' : '') . '">'; $bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ? previous_post_link('%link »', '%title', TRUE) : next_post_link('« %link', '%title', TRUE); echo ' </div>' . ($bfa_ata['home_single_next_prev'] != '' ? '<div class="home"><a href="' . $bfa_ata['get_option_home'] . '/">' . $bfa_ata['home_single_next_prev'] . '</a></div>' : '') . '<div class="newer' . ($bfa_ata['home_single_next_prev'] != '' ? '-home' : '') . '"> '; $bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ? next_post_link('« %link', '%title', TRUE) : previous_post_link('%link »', '%title', TRUE); echo '</div><div class="clearboth"></div></div>'; } } } |
All times are GMT -6. The time now is 02:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.