zxcvzfdvg

Archive for March, 2009

The Wordpress Structure

Sunday, March 29th, 2009

One of the things that drove me nuts when first learning Wordpress was figuring out what page was driven by which php code. I mean really there was a page called single.php a page called page.php, the index and more.

Easy to figure out was the header, footer and sidebars. Self explanatory… header.php - stuff at the top of the page, footer.php at the bottom and SURPRISE - sidebar.php was that stuff on either the left, right or both sides of the page.

But what page was delivered when someone clicked on the main navigation links - and what about a category - or a specific post. When trying to edit what showed up on these pages - frustration quickly set in.

So an Internet search ensued. I got a lot of great information form already knowledgeable Wordpress developers, and then I ran across the ULTIMATE resource - at least for me… a graphical depiction of how the hierarchical structure of Wordpress works.

wordpress structure

Click on image for full size view.

This picture shows exactly what page is served when a user clicks on various elements within the Wordpress platform, and what happens if that page doesn’t exist. I find it an indispensable tool when designing themes or using themes from other designers.

Exclude Pages from Main Navigation

Friday, March 13th, 2009

In the BlueBiz Theme and most themes for that matter, the main navigation is set up to list all the pages you create in WordPress. While that is great on many levels, there are times when you may not want to include a page in your main navigation system. There are a couple of ways to get around this. We will cover both…

If you are a plugin junkie

Simply download the Exclude Pages plugin by Simon Wheatley. This nifty little plugin “…adds a checkbox, “include this page in menus”, which is checked by default. If you uncheck it, the page will not appear in any listings of pages”

If you are new to plugins, that’s ok - to install of course, first download the package utilizing the link above. Then:

  • Unzip the contents of the package
  • Upload the package to the Wordpress plugins directory, the path is wp-content/plugins
  • Log in to your administration panel
  • Activate the plugin

and then as Simon so eloquently puts it: “Create or edit a page, and enjoy the frisson of excitement as you exclude it from the navigation.”

Or Maybe you wanna play with some code?

This option will require that you play with the code of Wordpress a bit. The first trick is determine which file is housing the main navigation. In the BlueBiz Theme it is in the header.php file. Some themes place the menu in the sidebar. Take your best guess, then open that file in a plain ascii text editor. DO NOT use word or anything like it!

  • Now look for some code that looks like php wp_list_pages(’SomeStuffInHere’ ); In the BlueBiz Theme, the SomeStuffInHere is exactly php wp_list_pages(’title_li’ );
  • Change that by adding an exclude argument to make it look like this php wp_list_pages(’exclude=210&title_li’ );

Now by now you may be asking yourself - how the heck do i know what number to put in there. Very good question! To find the number of the page you would like to exclude, log into your administration panel of Wordpress. Go to the Edit pages. Hover your mouse over the page you would like to edit, and look in the lower left corner of your screen, in the grey area. There will be a bunch of gobbldygoop there. What you are looking for is a post number. It looks like this action=edit&post=SomeNumber.

Now remember that number and fill in the appropriate number in the line of code. If you want to exclude several pages, simple add a comma in between the numbers. There you have it. Now those page numbers are excluded.

There are also several other arguments you can add to the wp_list_pages tag. All of them can be found at the Wordpress Codex. Check ‘em out and have some fun!