WordPress Info at sieker.info

WP-PagesNav

WP-PagesNav has it’s own page now, please go to WP-PagesNav.

The first release of my first WordPress plugin. The splendid WP-PagesNav. WP-PagesNav is a plugin which can be used to display a navigation bar using the static pages in your blog. Since my writing skills aren’t the best and a picture says more than a thousand words..

displays the pages across the top of the blog header
You can get the plugin here.

63 Comments

March 15th, 2005 WordPress Plugin: WP-PagesNav WP-PagesNav is a plugin which can be used to display a navigation bar using the static pages in your blog. Y […]

Thanks for doing this! I’m looking over your code and the results, and I think I would like to modify it somewhat. I see that you’ve made your function spit out a list with custom css classes. What I’d like to do is modify the pages list (the result of wp_list_pages) to show or hide the appropriate children, but not fuss with additional classes.

In other words, I think that what I’d like is something that adds a parameter to the wp_list_pages that says list all parent levels going back up to root, and list children for current page, and siblings for current child. If I decide that I’d like to turn the result of wp_list_pages into an inline list that runs across the top of the page rather than on the sidebar, I’d like to do that using my own flavor of css on the current tags. (That’s theory as yet untested because I haven’t yet gotten there. I still have to get the parent/child thing working first)

I’ll think about how to style it some more. Maybe the thing to do is generate a list whose ID is unique, say, id=”pageslist” and then style css parameters for the children of that list? Anyway, I’ll think some more about that.

Comment by Susan Kitchens — 18 March 2005 at 23:17

er, I see that you do some funky stuff with markup in your comment tags… It italicised a bunch of things, whereas I attempted to write down the WP function names with underscores. I’ll try it using the code tag: wp_list_pages

Comment by Susan Kitchens — 18 March 2005 at 23:19

Bug report #1, small change to make.

Line #115, at very end of line. Add \n to end of string:
From: </li>";
To: </li>\n";

makes for cleaner, more understandable list code.

Sorry for not reporting this bug to repository, your link doesn’t go to YOUR page for the plugin, but to general page. I’m just telling you which changes I’m making as I make them.

Comment by Susan Kitchens — 18 March 2005 at 23:52

Thanks a bunch for the plugin! I was attempting to write something like this myself the weekend, and then I stumbled across this. It’s simple and beautiful, and helps me in my efforts to achieve XHTML Strict. ;-) Putting it to good use on http://radio.mcad.edu/.

Comment by Paul Wenzel — 20 March 2005 at 11:34

Very nice plugin! I just downloaded and tested it. So what does it really do:
When using WordPress as a general contage management system (CMS) WP-PagesNav is a great “improvement” (addon) to the existing WordPress distribution. It allows for high usability for designers.
Thx

Comment by Ola Jetlund — 20 April 2005 at 12:48

plug is great.. i had worked around.. and worked around.. this helps quite a bit.

just wondering if it is as simple as including a style callout, but i can’t seem to figure out how to mark/highlight (differntly than the child.. ui thing, to give a trail fo bread crumbs) the parent(s) of the current child?

Comment by ptryk — 30 July 2005 at 13:15

worked it out.. added a bit in the middle .. ‘tween lines 111 and 112..


			// for parent menu highlighting .. code added here .ptryk //
			$page_currentparent = 0;	
			if (in_array($page_id, $parents, true)) {
				$page_currentparent=1;
			}
			if( $page_currentparent == '1'){
				$css_class .= 'currentparent';
			}
			// to here//

also.. to control it, put in a style in the style.css


#pages_nav li.currentparent a {
	color: #333;
	background: #FFF;
	text-decoration: none;
	border-bottom: none;
}

and it works quite nicely.. i assumed it should always be “on” but one never knows; i leave any further implementation / expansion up to you now..

although…. i am thinking about how to exclude pages.. hmmmmm

Comment by ptryk — 30 July 2005 at 16:33

made some more modifications.. needed a menu item/page to the home / index page to come up as current AND to have that page link to the index; added a number of lines.. seems to run smoothly.. send me an email and i will send you over the code (can’t seem to spot an email address anywhere)

Comment by ptryk — 1 August 2005 at 4:04

Am I stupid, or is there no “usage” stated for this function. I would like to use it but can’t figure out the usage syntax. I’ve looked at the code, and it is barely documented. I see 3 args that can are parsed . . . but what purposes do they serve? C’mon . . .

Comment by Chip — 4 August 2005 at 4:24

Hi Chip,

there is a readme.txt in the zip file.
Which which explains the recognized parameters and also explain their usage.
I did assume familiarity with php when writing the readme.txt
since you will have to edit your theme file to use it.

adi

Comment by adsworth — 4 August 2005 at 11:24

Nice Plugin. But is it possible to get such a Plugin für Post-Categories? I dont have much Categories inmy pages, but many posts… but I dont know a way to get to post-categories in a nice way…

The functions of your plugin for posts whould solve all my problems. :-)

Best regards!

Comment by Jens — 4 August 2005 at 16:32

Hi Jens,

I’m not quite sure what you want.
But you could have a look at the query_posts function
http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters and at wp_list_cats http://codex.wordpress.org/Template_Tags/list_cats

a combination of both might do what you want.

adi

Comment by adsworth — 6 August 2005 at 16:49

Hi

Brilliant plug-in. I am using it very effectively at http://www.swmug.co.uk.

Thank you so much.

Rich

Comment by Richard Brown — 9 August 2005 at 12:44

I have the plugin working, but it does not display the list items in a proper tree form. Here’s what I’m getting:

Item_1
Item_2 (selected)
Item_3
–Item_2_1
–Item_2_2
–Item_2_3

Shouldn’t I be getting:

Item_1
Item_2 (selected)
–Item_2_1
–Item_2_2
–Item_2_3
Item_3

Shouldn’t the child items be placed directly below the parent item and not at the end of the parent list?

Comment by Romme — 14 September 2005 at 3:50

I was able to leave proper breadcrumbs (highlighting the parent link) by adding the following after line 111 (just below $css_class = ”;)


                if( $page_id == $page_tree[$r['current']]['parent']) {
        			$css_class .= 'currentparent';
        		}

Enjoy it!

By the way, thank you Adsworth for a much needed plugin!

Comment by Jesse Haubrich — 24 September 2005 at 0:31

This is something i\’ll be needing shortly.
Thanks

Comment by Vishnu — 16 October 2005 at 22:30

Hi!

I wonder if anyone has successfully used this nav as follows:

0. Rootpage1 | 1. Rootpage2
0. Children1 | Children2 etc

and when You’re on page “Children2″, it’s parent, “0. Rootpage1″ is highlighted aswell as the currentpage? I don’t get this to work!

Comment by Johan — 30 November 2005 at 20:11

Hi,

I active the plugin. But where do i set the code?
< ?php
if(function_exists("wp_pages_nav")) {
wp_pages_nav("show_all_parents=1&show_root=0");
}
?>
I try in header.php replace this code < ?php wp_list_pages('title_li='); ?>
When i do this i see nothing no pages.

Michel

Comment by Michel — 12 December 2005 at 0:25

Jesse,
I modified your code a bit for the latest version… just a few small tweaks:

if( $page_id == $page_tree[$r[’current’]][’parent’]){
$css_class .= ‘currentparent’;
}

Comment by Ken Westin — 16 February 2006 at 2:45

Hi Jesse,

I’ll add that my version for the next release.

Thanks
Adi

Comment by Administrator — 18 February 2006 at 14:53

Hello Adi,

Great plugin, but I can’t seem to get the sort order to function.

I added the sort_column param to:
wp_pages_nav(”show_all_parents=1&show_root=0&sort_column=menu_order”);

but it doesn’t seem to work anyway.

Do you know why?

Comment by Joel — 9 March 2006 at 22:59

EDIT: well now the underscores dissapeared from my previous comment, but I guess you know what I mean anyway… I want to be able to sort the pages by giving them “page order” in the wordpress admin

Comment by Joel — 9 March 2006 at 23:03

Oh, I’m doing the change in template-source.php by the way…

(sorry for so many comments)

Comment by Joel — 9 March 2006 at 23:07

Hi Joel,

I use it like this:
wp\_list\_pages(’sort\_column=menu\_order&title\_li=’);
in sidebar.php and the sort order works fine for me.
I guess template-source.php is part of your wordpress theme, right?

Regards
Adi

Comment by Adi J. Sieker — 10 March 2006 at 13:53

How might I get it to show the path to the current page, without also showing the children of that page? At the moment, I’m using

wp_pages_nav(”show_all_parents=1&show_root=1&sort_column=menu_order”)

to always show the top-level pages and also to show the path to the current page, but it then also shows the child pages. Basically, I would like the row with the higlight to be the last row.

Comment by Murray Cumming — 10 March 2006 at 14:47

Does anyone have a .patch file (generated with diff -up, and applied with patch) for that parent-highlighting hack, mentioned above by Ken Westin and Jesse? I can’t get it to work, and it doesn’t seem to be in the released .zip yet.

Comment by Murray Cumming — 10 March 2006 at 15:36

Joel,

you do need to add:
wp\_pages\_nav(”show\all\parents=1&show\root=0&sort\column=menu\order”);
to one of your template files. The template-souce.php file in the plugin is an example of what to add to your own theme file. If you are using the default theme you could for example replace the call of wp\_list\_pages with your call of wp\_pages\_nav.

adi

Comment by Adi J. Sieker — 10 March 2006 at 21:15

Hi Murray,

to your first post:
ul of the childern gets it’s own css class. So you could try adding this to your themes style sheet:
ul .children { display: none;}
the contents will still be there just not displayed.
I’m just about to release a new version with the currentparent patch applied.

adi

Comment by Adi J. Sieker — 10 March 2006 at 21:38

Hello,
where do i set the code in header.php for pool theme
if(function_exists(”wp_pages_nav”)) {
wp_pages_nav(”show_all_parents=1&show_root=0″);
}
?>

Thanks for your help

Comment by Dav — 14 March 2006 at 19:43

Hi Dav,

in header.php there should be a call to:
wp\_list\_page(….)
I replaced that with:
wp\_pages\_nav(”sort\_column=menu\_order&show\_all\_parents=0&show\_root=1&list\_tag=”);

I hope that helps you out a little.

adi

Comment by Adi J. Sieker — 14 March 2006 at 19:58

[…] The new menu uses the WP-PagesNav plugin by Adi Sieker which seems to work very well now that I have figured out how to use it. I had to make a minor change to the plug-in code as it didn’t quite work as expected - the plug-in has an option to suppress the leading ul tag on the first level so that you can add links, such as a link to home, but it also suppressed the closing ul tag for the first level as well, meaning that the code was not valid. Still, it was only a small edit and it really is a good plug-in. Thanks to Adi. I believe the plugin will output the whole menu to as many levels as you want although I have only tested it to 4 levels. With this many sub-pages you could quite easily add thousands of pages if you really wanted to. I hope that this will be more than enough for anybody! The neat thing is that the whole thing works dynamically so the sub-page menu only appears when sub-pages are available and outputs to a single div with each page levels output to an unordered list. As far as horizontal menus are concerned it is far better than the WordPress default. The only thing that remains is to style the menu and get it looking something like the original. Hopefully this will be easy so bear with me for a couple of days and I hopefully will be able to set up a demo site. […]

Pingback by Webgazette.co.uk » Blog Archive » Sub-Page Nightmare — 29 March 2006 at 12:02

hi,

nice plugin. this question came already up but is still unanswered.


“I wonder if anyone has successfully used this nav as follows:
Rootpage1 | 1. Rootpage2
Children1 | Children2 etc

and when You’re on page “Children2″, it’s parent, “0. Rootpage1″ is highlighted aswell as the currentpage? …”

thanks
dex

Comment by dexter — 4 April 2006 at 10:28

[…] The new horizontal menu is controlled by the WP-PagesNav plug-in by Adi Sieker that I have modified and inserted into the theme functions file. I’ve coded the plug-in into the theme because the menu just won’t work without it and it seemed to be an easier option for the end user than having to download and install the plug-in separately. […]

Hi all,

I am having the same problem in the Comment by Romme — 14 September 2005.

I have:
Item 1
Item 2
Item 3
Item 2_1
Item 2_2
Item 2_3

Shouldn’t it be displaying:
Item 1
Item 2
Item 2_1
Item 2_2
Item 2_3
Item 3

I am not sure why and how to fix this. Can someone help me please?

Thanks.

Comment by Sean — 7 April 2006 at 4:00

Hi Sean,

to get a tree like display of your pages you can use the standard wp_pages_list() function, which is shipped with WordPress.
wp\_pages\_nav can’t display the pages in a tree like manner.

adi

Comment by Adi J. Sieker — 11 April 2006 at 20:48

Hi dex,

this should be possible, but it seems that there is a little bug in the plugin.
I’ll have a look at, as soon as possible.

adi

Comment by Adi J. Sieker — 11 April 2006 at 20:50

“I’m just about to release a new version with the currentparent patch applied.

adi”

Any update on the parent patch? I have tried the above patches by Ken & Jesse but for some reason it highlights both parents.

- G

Comment by Gavin — 24 April 2006 at 19:30

I am having trouble getting this to validate as xhtml 1.0 strict. The script seems to leave out a UL tag and an end UL tag. Has anyone else had this problem?

Comment by molly — 28 April 2006 at 0:09

Hi molly,

good god 2 weeks, I am mostly lacking when answering comments. :(
You need to either remove the parameter list_tag=
or add the opening and closing ul tags yourself.

Regards
Adi

Comment by Adi J. Sieker — 15 May 2006 at 16:08

Hi,
I would like to show only the parent but none of the children.

I’m thinking of using the wordpress as CMS so there will be many pages that i don’t want to show in main navigation.

Is there an easy way to accomplish this? (if i use exclude it would be a really long list…)

Comment by John — 7 June 2006 at 16:17

Hi John,

you can try passing the paramter ‘depth=1′ to wp_pages_nav. Also have a look at wp_list_pages which is part of wordpress.

adi

Comment by Adi J. Sieker — 8 June 2006 at 14:10

[…] Great pages plugin from adsworth.info that helps with page navigation in WordPress. Andreas Viklund is using it in WP Andreas 09 but Litquake wanted the top menu to have different hover over qualities. I knew I could get the “current” state to be a certain class and could easily do it by manually putting in a menu, but then it would lose Andreas’s fantastically automated pages and sub-navigation. […]

Pingback by WP-PagesNav | Likoma — 23 June 2006 at 1:19

Hi,

Thanks for this plugin. I will ask the same question as two others have asked before —> where do you insert this code:

There is no indication as to whether or not this goes in to:
• header.php
or
• index.php
or
• [where else can it go?].php

:)

Please would someone let those of us who are less than familiar with where this code can go or should go, know where we can insert the code.

Many thanks in advance.

Comment by Lyndon — 10 July 2006 at 16:12

Oops - I mean this code…

Comment by Lyndon — 10 July 2006 at 16:13

Hrmm … once again!

.’s inserted to allow for the code to be displayed.

Comment by Lyndon — 10 July 2006 at 16:15

div id=”pages_nav”

?php
if(function_exists(”wp_pages_nav”)) {
wp_pages_nav(”show_all_parents=1&show_root=0″);
}
?

/div

If this does not display, then I give up! :)

Comment by Lyndon — 10 July 2006 at 16:16

Wow amazing plugin. Lifesave :)

A question - how can I modify it so that when viewing child pages, “current” is also applied to the parent page? (In fact, I’m hiding child pages alltogether, as these are being outputted into another div)

And one more - how can I force this plugin to show on posts as well as pages? When browsing my News category, it doesn’t seem to output anything :-?

Many thanks for your time.

Comment by 3stripe — 11 July 2006 at 23:08

Hi this is great hopefully somebody can help me.

I want to call the function twice on a page.
Once at the top to output only all the top level.

Once half way down to output all the children of the current selected top level.

Can this be achieved?

Comment by rob — 15 July 2006 at 15:03

I tried your plugin. I must however say that it given unwanted output. The main problem is, that your code differs so much from the code without your plugin, so that the whole menu css stuff fails.
I can send you examples if necessary

Furthermore, the subitems are placed at the end of the list no matter where they should actualy appear.

If I can help to improve this behaviour tell me what information is neccessary for you.

Matthias Pospiech

Comment by Matthias Pospiech — 13 August 2006 at 11:22

[…] WP-PagesNav […]

Pingback by Matthias Pospiech :: Verändern der Menustruktur in Wordpress — 14 August 2006 at 13:15

[…] You can also try the WP-pagesnav WordPress Plugin (http://wp.sieker.info/wp-pagesnav) which creates a dynamic menu utilizing the normal Page structure. This plugin includes dynamic highlighting and menus of multiple levels with options. [edit] […]

Pingback by Lilithsbyte » Hello world! — 22 September 2006 at 2:24

thanks for the plugin. work of genius. one little bit of life a bit easier !! :O)

Comment by James in Cala Dor Palma de Mallorca — 24 September 2006 at 18:33

Hi thanks a lot for this great plugin,
I love it,

but is there any way to exclude pages?

regards
Monika

Comment by Monika — 7 October 2006 at 14:03

Cool blog…absolute pleasure to read your material.

Comment by Broadband Reviews — 7 October 2006 at 14:42

Hi Adi, nice plugin.

I’ve been playing with it but something confuses me, the show_root parameter doesn’t seem to do anything. Setting it to 1 or 0 makes no difference, would you kindly look into this matter?

I’ve tried looking through your php source code, and I’m very confuse at how show_root would contribute to anything. If it does, I appologise for over looking it. Please kindly explain. Thank you.

Seige

Comment by Seige — 3 November 2006 at 7:24

Love the Plug-in as well. I did have a question about copy rights. Would we need to edit the content or is it just as is? If so how is it workable?
Thanks,

Suzie
www.performers-world.com
suzie@performers-world.com

Comment by Don Lapre Girl — 3 November 2006 at 21:39

Hi Suzie,

you don’t need to edit the plugin. You need to edit your WordPress theme to add the plugin to the theme.
And you need to add the css information of the plugin to the css file of your theme and modify it.

I hope this helps you along a little.

adi

Comment by Adi J. Sieker — 5 November 2006 at 15:15

My english is not so good. I hope you will understand me. I have a big problem: How can I show only the root - not the children? In the readme.txt says:
“The following parameters are recognized:
- show_all_parents […]
- show_root […] then also the top most pages are displayed.”
Where do I have to put - show_root - so that only the parents get activated?
I hope somebody knows what I’m talking about.
Thanks
Conny

Comment by Conny — 25 November 2006 at 0:55

I was just wondering if this can be used for category aswel. I’m kind of new to wp and recently installed a new theme.

Regards,

Rick

Comment by forumgids — 21 December 2006 at 22:55

Hi Rick,

no wp_pages_nay can’t be used for categories,
although that a nice idea.
I’ll kep it in mind.

adi

Comment by Adi J. Sieker — 22 December 2006 at 13:19

Hi Conny,

in the current release it’s not possible to only display the root pages only.
I’m going to relese a new version with in a couple of weeks that supports only displaying the root pages.

adi

Comment by Adi J. Sieker — 22 December 2006 at 13:20

[…] Par un concours de circonstance, j’ai fini par retourner chez l’auteur du thème WP-Andreas09 1.9. Et là, heureuse surprise, non seulement la dernière version offre de nouvelle couleur de bandeau d’en-tête, mais la gestion par sous-menu a été incorporée en adaptant un plug-in —que je ne connaissais pas— permettant la gestion des menus et sous-menus. Si vous êtes plus intéressés par le plug-in que par le thème, il s’agit de WP-PagesNav de/par Adi Sieker. Très joli et efficace travail. […]

Sorry, the comment form is closed at this time.