Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1621 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

wordpress nav help

Thread title: wordpress nav help
Reply    
    Thread tools Search this thread Display Modes  
10-01-2009, 01:05 AM
#1
jasonm56 is offline jasonm56
jasonm56's Avatar
Status: I love this place
Join date: Jun 2007
Location: Minneapolis
Expertise: xhtml/css, jquery, php, mysql
Software:
 
Posts: 533
iTrader: 1 / 100%
 

jasonm56 is on a distinguished road

Send a message via MSN to jasonm56

  Old  wordpress nav help

I understand that I can have a nav menu in wordpress, with each link going into a different category (each post is under a specific category, so its just narrowing it all down). HOW would I be able to have a "current page"? For instance, you click on the "tutorials" link, but on your nav menu, it just looks plain, giving no sign of what page your on. With php, and only one index page, how can you accomplish this?

Reply With Quote
10-01-2009, 08:52 AM
#2
Garyrae is offline Garyrae
Status: Request a custom title
Join date: Dec 2005
Location: Colchester, UK
Expertise:
Software:
 
Posts: 4,625
iTrader: 16 / 100%
 

Garyrae is on a distinguished road

Send a message via MSN to Garyrae Send a message via Skype™ to Garyrae

  Old

Code:
<li<?php if(is_category('tutorials') || in_category('tutorials')) { echo ' class="current"'; } ?>><a href="<?php get_option('home'); ?>/tutorials/">Tutorials</a></li>
Sorta thing.

Basically that adds ' class="current"' to the <li>, if the user is viewing the category archive for 'Tutorials', or the post they're viewing is in the 'Tutorials' category.

Reply With Quote
10-02-2009, 10:17 PM
#3
jasonm56 is offline jasonm56
jasonm56's Avatar
Status: I love this place
Join date: Jun 2007
Location: Minneapolis
Expertise: xhtml/css, jquery, php, mysql
Software:
 
Posts: 533
iTrader: 1 / 100%
 

jasonm56 is on a distinguished road

Send a message via MSN to jasonm56

  Old

Originally Posted by Garyrae View Post
Code:
<li<?php if(is_category('tutorials') || in_category('tutorials')) { echo ' class="current"'; } ?>><a href="<?php get_option('home'); ?>/tutorials/">Tutorials</a></li>
Sorta thing.

Basically that adds ' class="current"' to the <li>, if the user is viewing the category archive for 'Tutorials', or the post they're viewing is in the 'Tutorials' category.
I understand that, but the problem is I don't know how to turn my "tutorials" category into an archive page. Not sure if thats making sense, but the closest thing I can think of is how Smashing Magazine is set up.

Reply With Quote
10-02-2009, 10:30 PM
#4
Garyrae is offline Garyrae
Status: Request a custom title
Join date: Dec 2005
Location: Colchester, UK
Expertise:
Software:
 
Posts: 4,625
iTrader: 16 / 100%
 

Garyrae is on a distinguished road

Send a message via MSN to Garyrae Send a message via Skype™ to Garyrae

  Old

Just add a conditional inside the loop of the archive.php template.

PHP Code:
<?php
while(have_posts()) : the_post();
    if(
is_category('tutorials')) {
        
// code for the tutorial post
    
} else {
        
// normal post code
    
}
endwhile;
?>

Reply With Quote
10-02-2009, 10:50 PM
#5
Jordan is offline Jordan
Jordan's Avatar
Status: #pugs {display: block;}
Join date: Jan 2007
Location: Chicago
Expertise: CSS, HTML, PHP
Software: Sublime Text 2
 
Posts: 1,187
iTrader: 7 / 100%
 

Jordan is on a distinguished road

  Old

Wordpress adds in a class on it's own, so you don't need to bloat it with more code.

wp_list_categories is the function you'd use within Wordpress.

Code:
 <ul>
        <?php wp_list_categories('&title_li='); ?>
 </ul>
That will simple just display all of your categories and will hide the heading that can be output.

The classes attached that would achieve the effect you need are li.current-cat {} and li.current-cat-parent {}. Styling those will show the "current" category you're in for your navigation.

Reply With Quote
10-02-2009, 11:11 PM
#6
jasonm56 is offline jasonm56
jasonm56's Avatar
Status: I love this place
Join date: Jun 2007
Location: Minneapolis
Expertise: xhtml/css, jquery, php, mysql
Software:
 
Posts: 533
iTrader: 1 / 100%
 

jasonm56 is on a distinguished road

Send a message via MSN to jasonm56

  Old

ahhh Looks like I need to create an archives page first ahaha

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed