Home > WordPress > Hack: Don't show menu item if page order = -1

Hack: Don't show menu item if page order = -1

December 17th, 2006 Leave a comment Go to comments

I was tired of trying to exclude every page that I didn’t want to show up. Wow could that system be more clunky..

So, I made it so if the menu_order = -1 it just skips it.

File: wp-includes/template-functions-post.php
Line: 366

Find the following:

// Now loop over all pages that were selected
$page_tree = Array();
foreach ( $pages as $page ) {

Just after it place the following:

// If the menu_order == -1 then skip it
if ($page->menu_order == '-1') {
break;
}

Simple.

Categories: WordPress Tags:
  1. December 17th, 2006 at 20:58 | #1

    I highly recommend doing as many hacks as possible in your own custom set of templates, as the upgrade method basically entails blindly overwriting files and potentially losing whatever work you do.

    You could try to keep track (local svn repository?), but keeping as much as possible out of the PHP code will make things easier.

    That said, all your content will sit in the database, which doesn’t take long to understand (and migrate from). And their security updates tend to stay on the simple enough side that you can just make the change(s) yourself in two minutes.

  2. December 17th, 2006 at 21:20 | #2

    Yeah I realize that this will be an issue..

    I hope to keep the “hacks” simple enough that if I do forget or miss one when I update, they will be easy to put back.

    I’m trying to stick with just the templates but some stuff has to be done outside the template as the template just has a function name that outputs stuff..

  1. No trackbacks yet.