How to remove your front page from WordPress search results

If you use a static front page for your WordPress site, depending on its contents and structure it may show up in your search results – you may (or may not) want this to happen.

If you don’t want to see your front page in your search results, add this code to your functions.php file:

add_action( 'pre_get_posts', 'edinburgh_wp_exclude_front_page_from_search' );
function edinburgh_wp_exclude_front_page_from_search( $query ) {
    if ( $query->is_main_query() && $query->is_search() ) {
        // Get an array with page ID of front page 
	$pageID = array(get_option('page_on_front'));
 	$query->set('post__not_in', $pageID);

If you use a ‘regular’ setup and have a home page and not a static front page, use this slightly different function to exclude the home page from search results.

add_action( 'pre_get_posts', 'edinburgh_wp_exclude_home_page_from_search' );
function edinburgh_wp_exclude_home_page_from_search( $query ) {
    if ( $query->is_main_query() && $query->is_search() ) {
        // Get an array with page ID of home page
	$pageID = array(get_option('page_for_posts'));
 	$query->set('post__not_in', $pageID);

The best way to customise the categories widget in WordPress

You may not like how WordPress’ Categories widget lists categories – particularly if you want to modify the list that’s displayed and hide some categories or have a custom order of categories (rather than alphabetical or by number of posts).

So what’s the easiest way to customise the display of the Categories widget??

You don’t.

Create a new *menu*, add the categories that you want in the order you want them, and add your new menu to the widget area.

So you can go from this:

to this:

You’ve created a custom post type, but WordPress says your posts can’t be found…

This strange thing happened to me earlier today – added a custom post type earlier this week, published an article this afternoon – but then I couldn’t view the published version – WordPress said it couldn’t be found (404 error).


Go to your dashboard, and then to settings/permalinks.

Scroll to the bottom and click “Save Changes”. This will force WordPress to update permalink settings and your posts in your custom post type should now work.