Jump to content

Recommended Posts

Here's php code:

<ul>

<?php wp_list_pages() ?>

</ul>

 

The wp_list_pages automatically creates the <li>'s for all my pages and it displays like this:

Home About Contact...

I would like it to display like this:

Home | About | Contact... any ideas about how I might force a seperator to be used between the pages?

Link to comment
https://forums.phpfreaks.com/topic/63229-solved-add-a-seperator/
Share on other sites

wp_list_pages is built into one wordpress' many files and I wouldn't even know where to begin to edit it.  How would I go about creating (in my themes stylsheet) a way to possibly add text effects to the <li>'s for exaple when the mouse is active over one of the links it adds a highlight to the text? and how would I tell the <ul> to display it?  somthing like <ul class="header_pages"> or something like that???

Ok I know just enough about css and php to get in trouble, so here is the code any help would be appreciated:

CSS <ul>,<li> code for header navigation:

#topnav

{

list-style:none;

font-size:0.9em;

margin:0 auto;

padding:12px 20px 0 0;

text-align:right;

font-family:Verdana, Arial, Sans-Serif;

}

#topnav li

{

list-style:none;

display:inline;

padding:0;

margin:0;

font-weight:bold;

}

 

#topnav li a:link, #topnav li a:visited

{

text-decoration:none;

color:#BBC4A3;

}

#topnav li a:hover, #topnav li a:active

{

color:#F7F3ED;

}

 

CODE to display it:

<ul id="topnav">

<?php wp_list_pages('title_li=&depth=1'); ?>

</ul>

This is an old trick. It uses floats and negative margin to properly align the pipe.

 

First, designate a container for the nav with a 1em bottom margin and hidden overflow.

 

As you have done, do not specifically style "ul" - you will use the <ul id="">tag.

 

Then style the li to use a negative left margin and 1.1 line height (because you designated the 1em bottom margin):

 

#topnavwrap
{
margin-bottom: 1em;
overflow: hidden;
width: 90%;
}
#topnav
{
list-style-type: none;
   font-size:0.9em;
   margin:0 auto;   
   padding:12px 20px 0 0;
   text-align:right;   
   font-family:Verdana, Arial, Sans-Serif;
}
#topnav li
{
border-left: 1px solid #000;
float: left;
line-height: 1.1em;
margin: 0 .5em 0 -.5em;
padding: 0 .5em 0 .5em;
}
#topnav li a:link, #topnav li a:visited
{
text-decoration:none;   
color:#BBC4A3;
}
#topnav li a:hover, #topnav li a:active
{
color:#F7F3ED;   
}

 

Here is the whole page to see it in action:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {background-color:#0099CC}
#topnavwrap
{
margin-bottom: 1em;
overflow: hidden;
width: 90%;
}
#topnav
{
list-style-type: none;
   font-size:0.9em;
   margin:0 auto;   
   padding:12px 20px 0 0;
   text-align:right;   
   font-family:Verdana, Arial, Sans-Serif;
}
#topnav li
{
border-left: 1px solid #000;
float: left;
line-height: 1.1em;
margin: 0 .5em 0 -.5em;
padding: 0 .5em 0 .5em;
}
#topnav li a:link, #topnav li a:visited
{
text-decoration:none;   
color:#BBC4A3;
}
#topnav li a:hover, #topnav li a:active
{
color:#F7F3ED;   
}
-->
</style>
</head>

<body>
<div id="#topnavwrap">
<ul id="topnav">
	<li id="active"><a href="#" id="current">Item one</a></li>
	<li><a href="#">Item two</a></li>
	<li><a href="#">Item three</a></li>
	<li><a href="#">Item four</a></li>

	<li><a href="#">Item five</a></li>
</ul>
</div>
</body>
</html>

 

Works every time.

 

Dave

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.