From website design to social media strategies, everything you need to create a robust online presence. Planning, creating, writing, presenting… whatever your seminar or workshop needs, we can help. For the entrepreneurial author. We can help you create, publish, and distribute your book. Present a consistent and compelling message about your business to the world through a professionally designed visual brand. Engage with your local community and build relationships that will catapult your business into Thought Leadership. Bootstrap your creative process with a workshop, class, or retreat. Image Map

Become a Thought Leader


Thought Leader - n. -
A recognized expert in a particular field.
Build credibility and trust within your community.
Start attracting business instead of chasing after it.
Social Bootstrap can help!
Learn more about Social Bootstrap

WordPress Plugin Tutorial: Exclude Pages

When using WordPress as a CMS, sometimes you have to trick out page menu bars. I often run sites with many static pages that I don’t want showing up in menus or (especially) in the commonly used horizontal page menu bar. And I don’t want to make them all child pages of something. That would be weird.

Thankfully, as with almost everything in WordPress, as soon as I realized I had a problem, I was able to find someone who had already solved it for me. The Exclude Pages Plugin by Simon Wheatley adds a convenient little checkbox to the Page Edit page, asking if you want to include this page in page menus.

Fantastic.

Changing the Default Setting on the Exclude Pages Plugin

Most of the time when I’m using this plugin, it’s because I have some particular small group of pages I want displayed in navigation menus. I want the default to be “DO NOT include this page.” This makes me (and my clients who like to add pages and pages and ruin my beautiful navigation bars) have to think less.

Unfortunately, the default setting for the Exclude Pages plugin is “YES, include this page.” I wanted to change that.

If you’re using the Exclude Pages Plugin, and want to make the default setting an unchecked box, go into the exclude_pages.php file. (I did this right from the Plugin Editor inside the WordPress admin area.) Find the function called “ep_this_page_included” and change the first “return true” to “return false.”

Here’s what it looks like in the code:

BEFORE:

function ep_this_page_included()
{
	global $post_ID;
	// New post? Must be included then.
	if ( ! $post_ID ) return true;
	$excluded_ids = ep_get_excluded_ids();
	// If there's no exclusion array, we can return true
	if ( empty($excluded_ids) ) return true;
	// Check if our page is in the exclusion array
	// The bang (!) reverses the polarity [1] of the boolean
	return ! in_array( $post_ID, $excluded_ids );
	// fn1. (of the neutron flow, ahem)
}

AFTER:

function ep_this_page_included()
{
	global $post_ID;
	// New post? Do NOT include!
	if ( ! $post_ID ) return false;
	$excluded_ids = ep_get_excluded_ids();
	// If there's no exclusion array, we can return true
	if ( empty($excluded_ids) ) return true;
	// Check if our page is in the exclusion array
	// The bang (!) reverses the polarity [1] of the boolean
	return ! in_array( $post_ID, $excluded_ids );
	// fn1. (of the neutron flow, ahem)
}

Now, new pages do not display in menus by default, but can easily be turned on in their Edit page if you want them to.

  • Share/Bookmark

5 comments to WordPress Plugin Tutorial: Exclude Pages

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>