TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-03-2008, 11:06 AM   #1 (permalink)
The Visitor
 
Join Date: May 2008
Posts: 3
Thanks: 0
ncmason is on a distinguished road
Default WordPress "current_page_item"

I can't get this figured out...

I'm using the wp_list_pages function in WordPress to show my pages in my navbar.

I was able to make some edits to the classes.php file in "/wp/wp-includes".

PHP Code:
PHP Code:
<?php if (is_home()) {$highlight "page_item";} else {$highlight "current_page_item";}?> 

    <div id="navbar"> 
            <ul> 

                <li class="<?php echo $highlight?>"><a href="<?php echo get_settings('home'); ?>">Home</a></li> 
                <?php wp_list_pages('title_li='); ?> 
            </ul> 
        </div>
Above is the code for my navbar.

I want the HTML output to look like this:

HTML Code:
<li class="current_page_item"><a href="http://masonsklut.com">Home</a></li>
<li><a href="http://masonsklut.com/archives/">Archives</a></li>
<li><a href="http://masonsklut.com/contact/">Contact</a></li>
<li><a href="http://masonsklut.com/donate/">Donate</a></li>
Thanks,
Mason

Last edited by ncmason : 03-18-2009 at 10:41 PM.
ncmason is offline  
Reply With Quote
Old 11-03-2008, 11:27 AM   #2 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

nvm, i read the WP manual, it seems my solution wasnt a solution after all, i'll keep looking though!
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 11-03-2008, 11:29 AM   #3 (permalink)
The Visitor
 
Join Date: May 2008
Posts: 3
Thanks: 0
ncmason is on a distinguished road
Default

It displays the pages either way. I've never used it with 'echo'.

This is the code in classes.php that changes the output of wp_list_pages:

PHP Code:
extract($argsEXTR_SKIP);
        
$css_class '';
        if ( !empty(
$current_page) ) {
            
$_current_page get_page$current_page );
            if ( 
in_array($page->ID, (array) $_current_page->ancestors) )
                
$css_class .= ' current_page_ancestor';
            if ( 
$page->ID == $current_page )
                
$css_class .= 'current_page_item';
            elseif ( 
$_current_page && $page->ID == $_current_page->post_parent )
                
$css_class .= ' current_page_parent';
        }

        
$output .=     '<li class="'$css_class '"><a href="' get_page_link($page->ID) . '">' apply_filters('the_title'$page->post_title) . '</a>'
ncmason is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:31 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design