Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Excerpts, Read more, Pagination (http://forum.bytesforall.com/forumdisplay.php?f=20)
-   -   [SOLVED] Hide next/previous navigation bar if there is just one post in a category... (http://forum.bytesforall.com/showthread.php?t=6135)

chiara7 Mar 3, 2010 03:53 PM

[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...

juggledad Mar 3, 2010 04:12 PM

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.

chiara7 Mar 4, 2010 05:25 AM

:( 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...

juggledad Mar 4, 2010 05:51 AM

the nav bars wont show unless you have more than one post in a category

chiara7 Mar 4, 2010 06:29 AM

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 &raquo;', '%title', TRUE) :
next_post_link('&laquo; %link', '%title', TRUE);

echo ' &nbsp;</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' : '') . '">&nbsp; ';

$bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ?
next_post_link('&laquo; %link', '%title', TRUE) :
previous_post_link('%link &raquo;', '%title', TRUE);

echo '</div><div class="clearboth"></div></div>';

}

}

juggledad Mar 6, 2010 04:05 AM

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
to
HTML Code:

        if ( !is_single() AND !is_page() AND !is_category() AND
and I think that will do what you want.

-------------------
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.

chiara7 Mar 7, 2010 04:42 PM

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 &raquo;', '%title', TRUE) :

next_post_link('&laquo; %link', '%title', TRUE);



echo ' &nbsp;</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' : '') . '">&nbsp; ';



$bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ?

next_post_link('&laquo; %link', '%title', TRUE) :

previous_post_link('%link &raquo;', '%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.