WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Genesis Widgetized Not Found & 404

Finally, use widgets to maintain and customize your 404 Error and Search Not Found pages in Genesis Framework and Child Themes.

How can I change the layout of the '404 Error Page' (i.e. go full-width)?

You can use my "Genesis Layout Extras" plugin for that, which has an option for the 404 case built in. Or you can also use my built in helper function and add this little line to your functions.php of your child theme (backup file before!) or to the "Custom Function" section of Prose Child Theme 1.5+:

/** Genesis Widgetized NotFound: 404 Error Page - Full-Width Layout */
add_action( 'genesis_meta', '__gwnf_layout_404_full_width' );

How can I change the layout of the 'Search not found' Page (i.e. go full-width)?

You can use my "Genesis Layout Extras" plugin for that, which has an option for the search case built in. -- Or you can also use my built in helper function and add this little line to your functions.php of your child theme (backup file before!) or to the "Custom Functions" section of Prose Child Theme 1.5+:

/** Genesis Widgetized NotFound: Search not found Page - Full-Width Layout */
add_action( 'genesis_meta', '__gwnf_layout_searchnotfound_full_width' );

Note: The above code is restricted to the case when NO search results are found! It doesn't effect your search results display IF THERE ARE any results!

How can I style the content/widget areas?

It's all done via your child theme. Maybe you need to add an "!important" to some CSS rules here and there... For more even better styling I included some IDs and classes:

  • "404 Error Page" section:
    • the whole content area, before and after all widgets is wrapped in a div with the ID: #gwnf-404-area
    • each widget in this area has its own ID depending on the widget (regular WordPress behavior!)
    • each widget gets an additional class: .gwnf-404 -- which allows to set some common styles for all widgets in this area
  • "Search not found" section:
    • the whole content area, before and after all widgets is wrapped in a div with the ID: #gwnf-notfound-area
    • each widget in this area has its own ID depending on the widget (regular WordPress behavior!)
    • each widget gets an additional class: .gwnf-notfound -- which allows to set some common styles for all widgets in this area

Note, WordPress itself additionally adds body classes in the 404 case and the search not found case. So you can also use these classes: .error404 and .search-no-results

If that's still not enough, you can even enqueue your own style, an action hook is included for that: gwnf_load_styles -- This hook fires within the WordPress action hook wp_enqueue_scripts just after properly enqueueing the plugin's styles and only if at least one of both widgets is active, so it's fully conditional!

Could I disable the Shortcode support for widgets?

Of course, it's possible! Just add the following constant to your child theme's functions.php file or to a functionality plugin:

/** Genesis Widgetized Not Found & 404: Remove Widgets Shortcode Support */
define( 'GWNF_NO_WIDGETS_SHORTCODE', TRUE );

Some webmasters could need this for security reasons regarding their stuff members or for whatever other reasons... :).

What are parameters of the plugin's own Shortcodes?

(1) Parameters for [gwnf-widget-area] Shortcode:

  • area -- ID of the Widget area (Sidebar) (default: none, empty)
  • The following values are accepted: 404 OR notfound OR bbpress-notfound

(2) Parameters for [gwnf-search] Shortcode:

  • search_text -- Search placeholder text (default: Search this website)
  • button_text -- HTML wrapper tag (default: Search)
  • form_label -- Additional label before the search form (default: none, empty)
  • wrapper -- HTML wrapper tag (default: Latest update date:)
  • class -- Additional custom CSS class for the wrapper (default: none, empty)
  • post_type -- Optional setup post type(s) for search (default: none, empty - i.e., WordPress default search behavior!)

Could I completely remove the plugin's Shortcode features?

Of course, that's possible! Just add the following constant to your child theme's functions.php file or to a functionality plugin:

/** Genesis Widgetized Not Found & 404: Remove Shortcode Features */
define( 'GWNF_SHORTCODE_FEATURES', TRUE );

Can I remove the widgetized content area for bbPress forum search "not found"?

Of course, that's possible - very easily :). Just add the following line of code to your child theme's functions.php file or a functionality plugin:

/**
 * Genesis Widgetized Not Found & 404:
 *  Remove bbPress Widgetized Content Area on "not found"
 */
add_filter( 'gwnf_filter_bbpress_noresults_widgetized', '__return_false' );

How can I customize the widget titles/strings in the admin?

I've just included some filters for that - if ever needed (i.e. for clients, branding purposes etc.), you can use these filters:

gwnf_filter_404_widget_title - default value: "404 Error Page"

gwnf_filter_404_widget_description - default value: "This is the widget area of the 404 Not Found Error Page."

gwnf_filter_notfound_widget_title - default value: "Search Not Found"

gwnf_filter_notfound_widget_description - default value: "This is the widget area of the search not found content section."

gwnf_filter_notfound_default - default value: "Sorry, no content matched your criteria. Try a different search?"

Example code for changing one of these filters:

add_filter( 'gwnf_filter_404_widget_title', 'custom_404_widget_title' );
/**
 * Genesis Widgetized NotFound: Custom 404 Widget Title
 */
function custom_404_widget_title() {
    return __( 'Custom Error Page', 'your-child-theme-textdomain' );
}

Final note: I DON'T recommend to add customization code snippets to your child theme's functions.php file! Please use a functionality plugin or an MU-plugin instead! This way you can also use this better for Multisite environments. In general you are not abusing the functions.php for plugin-specific stuff and you are then also more independent from child theme changes etc. If you don't know how to create such a plugin yourself just use one of my recommended 'Code Snippets' plugins. Read & bookmark these Sites:

All the custom & branding stuff code above can also be found as a Gist on GitHub: https://gist.github.com/2473125 (you can also add your questions/ feedback there :)

How can I use the advantages of this plugin for multlingual sites?

(1) In general: You may use it for "global" widgets.

(2) Usage with the "WPML" plugin: Widgets can be translated with their "String Translation" component - this is much easier than adding complex information/instructions to the 404 error or search not found pages for a lot of languages...

You can use the awesome "Widget Logic" plugin (or similar ones) and add additional paramaters, mostly conditional stuff like is_home() in conjunction with is_language( 'de' ) etc. This way widget usage on a per-language basis is possible. Or you place in the WPML language codes like ICL_LANGUAGE_CODE == 'de' for German language. Fore more info on that see their blog post: http://wpml.org/2011/03/howto-display-different-widgets-per-language/

With the following language detection code you are now able to make conditional statements, in the same way other WordPress conditional functions work, like is_single(), is_home() etc.:

/**
 * WPML: Conditional Switching Languages
 *
 * @author David Decker - DECKERWEB
 * @link   http://twitter.com/deckerweb
 *
 * @global mixed $sitepress
 */
function is_language( $current_lang ) {

    global $sitepress;

    if ( $current_lang == $sitepress->get_current_language() ) {
        return true;
    }
}

Note: Be careful with the function name 'is_language' - this only works if there's no other function in your install with that name! If it's already taken (very rare case though), then just add a prefix like my_custom_is_language().

--> You now can use conditionals like that:

if ( is_language( 'de' ) ) {
    // do something for German language...
} elseif ( is_language( 'es' ) ) {
    // do something for Spanish language...
}

Requires: 3.2 or higher
Compatible up to: 3.6.1
Last Updated: 2013-5-29
Downloads: 10,208

Ratings

4 stars
4.5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,3,3 100,5,5 100,4,4
100,1,1 100,2,2 100,3,3 100,5,5 100,4,4
67,3,2 100,3,3 100,3,3 100,5,5 100,4,4
100,4,4 100,5,5 100,2,2 100,4,4
100,4,4 100,5,5 100,2,2 100,4,4
100,3,3 100,2,2 100,4,4
100,4,4 100,2,2 100,4,4
100,2,2 100,4,4
100,5,5
100,2,2
100,1,1
100,1,1