WordPress.org

Ready to get started?Download WordPress

Forums

Page List problems (3 posts)

  1. steph-angel
    Member
    Posted 5 years ago #

    Hi... I'm still battling on with my site revamp and still hitting snags :-(

    I've been trying to customize a theme to my liking, but I'm having problems with the way the theme lists pages in the header as links... The first problem is that it will list absolutely every page in my site (and yes I have read about possible <?php wp_list_pages('title_li=&depth=1&page_sort=asc&exclude=1')?> ways around this, but the other problem I have is that that theme I'm using has a seperate pagelists.php file that deals with the page navigation and 'wp_list_pages' doesn't feature anywhere in it!!!

    I've even tried using a page plugin that gives the option to remove certain pages from the menu, but they still appear???

    Here's the pagelist.php file, which I'm hoping isn't too long!!!

    <li<?php if (is_home()) echo " class=\"active_page\""; ?>><a href="<?php bloginfo('url'); ?>"><span>Home</span></a></li>
    
    				<?php
    
    				$pages = CMSTheme_GetPages();
    
    				if ($pages) 
    
    				{
    
    					foreach ($pages as $page)
    
    					{
    
    						$page_id = $page->ID;
    
    						$page_title = $page->post_title;
    
    						$page_name = $page->post_name;
    
    						if ($page_name == "archives")
    
    						{
    
    							(is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ' class="active_page"':$selected='';
    
    							echo "<li".$selected."><a href=\"".get_page_link($page_id)."\"><span>Archives</span></a></li>\n";
    
    						}
    
    						elseif($page_name == "about")
    
    						{
    
    							(is_page($page_id))?$selected = ' class="active_page"':$selected='';
    
    							echo "<li".$selected."><a href=\"".get_page_link($page_id)."\"><span>About</span></a></li>\n";
    
    						}
    
    						elseif ($page_name == "contact")
    
    						{
    
    							(is_page($page_id))?$selected = ' class="active_page"':$selected='';
    
    							echo "<li".$selected."><a href=\"".get_page_link($page_id)."\"><span>Contact</span></a></li>\n";
    
    						}
    
    						elseif ($page_name == "about_short") {/*ignore*/}
    
    						else 
    
    						{
    
    							(is_page($page_id))?$selected = ' class="active_page"':$selected='';
    
    							echo "<li".$selected."><a href=\"".get_page_link($page_id)."\"><span>$page_title</span></a></li>\n";
    
    						}
    
    					}
    
    				}
    
    				?>
  2. moshu
    Member
    Posted 5 years ago #

    It is too long... and I'd simply delete (throw out) that pagelist file and use the normal wp_list_pages template tag instead, with all its parameters.
    Why overcomplicate things when there are simple, effective solutions?

  3. steph-angel
    Member
    Posted 5 years ago #

    I have ditched it, as I have with a lot of this overly complicated theme and I've simply replaced the page list menu for a simple horizontal list menu... I am stubbornly trying to get my head around the joys of PHP & CSS coding, but sometimes it's best to stick with what you know!!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags