HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

WordPress and Windows Server – Permission Problems

In the land of one-click installers, where any web host can get a WordPress site running with little-to-no user interaction, sometimes installing WordPress on a Windows server is an exercise in frustration.

While at it’s base level, you can use the Web Platform Installer to install WordPress but I’ve found that it is rarely that simple. With a lot of our clients, they decide that they want a blog to go with their existing non-WordPress site while keeping it on their main domain. This is understandable. I would probably want the same thing.

But what I’ve had to deal with ends up being a fight between user permissions and application permissions just to get WordPress running. While many may not have this problem, but it comes up frequently for me and for some reason I always forget what I did to resolve all my errors. So this time around, this post is not only meant to share with the world, it’s my own reminder when I have to do it again.

The issue arises when I install WordPress in a sub-folder of a parent website. This is because they usually want whatevertheirdomainis.com/blog to be the URL, and I like keeping things organized so I am ok with this.

I usually come across two different problems, and frequently they will both show up depending on my attempts to fix it.

The first error is an actual IIS error that is thrown in regards to the web.config file not having sufficient permissions. Often this error will appear first, and then after I had what I figured was the correct permissions, I end up with the second problem.

The second one is an infinitely loading page. I could leave it for hours and it will never time out, never throw an error, but just make an attempt to load the page forever.

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

The most likely resolution is to make sure that your IIS_IUSRS account has read access to the folder where the web.config is located. for the parent site. While this may not seem to resolve the issue, I found that I had to stop and restart the Application Pool in order for it to recognize the changes.

Some people suggested that you actually need to give the Application Pool created by the blog proper permissions, which you can access in the permissions settings by using IIS ApplicationPool\<applicationPoolName> but I haven’t found this to be the actual problem either time I’ve run into this but it is worth noting.

Microsoft also suggests this error can be caused by a malformed applicationHost.config file but this is highly unlikely to be caused by simply installing WordPress. Especially if you have other sites running already.

Just remember not to give the IIS_IUSRS account write access. And being on Windows, the first time you try to install a plugin or update WordPress, it will most likely ask for FTP credentials as well.

It’s amazing how easily you can forget something as simple as giving proper user permissions. Cheers!

Creating a WordPress Plug-in to customize the Dashboard

I’ve used many different plug-ins to accomplish the simple goal of modifying the dashboard to match the look and feel with the rest of the site. Some worked, some didn’t. And some were needlessly complicated. I thought “I bet this would be much easier if I just wrote my own custom CSS.”

But I didn’t want to mess with any core files, so I figured “Hey, if these plug-ins were loading additional CSS, I can too.” So I spent a bit time looking into how you write a plug-in and found it was really easy to load a CSS file.

This walk-through will go through the simple steps of creating your own WordPress plug-in that loads your own CSS file to the dashboard.

The first step we need to do is to create the folder for your plug-in and the default file. I created my plug-in for The Recipe Folder, so my folder is called “recipe-folder-admin-theme” and the default file is called, you guessed it, “recipe-folder-admin-theme.php”.

The contents of this file is similar to creating your own theme. In a php code tag add something like this:

/*Plugin Name: The Recipe Folder Admin Theme
Plugin URI: http://www.therecipefolder.com
Description: Custom Recipe Folder Admin Theme
Author: Daniel Gray
Version: 1.0
Author URI: http://demo.therecipefolder.com*/

Adjust to match your details. This adds the necessary information for WordPress to identify your new plug-in. To make the Dashboard load your custom CSS file, add the following lines (extra line breaks added to keep the post within the column of this post):

function my_wp_admin_css() {
echo 'css"
type="text/css" />';
}
add_action('admin_head','my_wp_admin_css');

As you can imagine, the CSS file can live pretty much wherever you want. You could host it remotely if you want to distribute changes automatically, though if you release it as a plug-in to people, they may not be fond of loading content from another source.

The add_action with the flag “admin_head” tells the plug-in where the function should be executed. In this case, the my_wp_admin_css function simply echos a link to a CSS file in the header of the admin page, which is the dashboard.

After that, it’s creating your CSS file and adjusting style to your heart’s content. Power up Firebug and start going to town.

A customized dashboard

Any questions or comments, be sure to leave them here!

Columns

Faux Mega Menu in WordPress

Sometimes you have so many items in your WordPress blog’s navigation that you feel that it’s far too long. But if they are in the proper logical division splitting them into other menus is not be an option.

There are fantastic tools to create “Mega Menus” with jQuery and CSS such as this one. But on the standard WordPress menu you find in themes like 2010 or Thematic, implementing can be a challenge sometimes.

Luckily for us we can use CSS3 for a quick fix to make your drop down menu split itself into columns. The most obvious answer is to use the new “Columns” property but unfortunately it is not widely supported, even among modern browsers.

For reference, in this example I am styling a drop down menu in Thematic.

.sub-menu{display:inline-block; width:500px !important;}

.sub-menu li{width:50% !important;}

.sub-menu li a:hover{color:#FFFFFF;}

.sub-menu li:nth-child(even){float:right;}

All we are telling it to do is to make the sub-menu 500px wide, make every list item 50% of that, and using the nth-child property, tell every even-numbered element to float right.

Making it 3 columns would be as easy as dropping the li width to 33% if we wanted. Applying styles is easy as well. If we wanted a border dividing the left and right column (if mine didn’t already have borders) we could further edit the nth-child(even) and give it a left border, or make a new rule for nth-child(odd) and give it a right border.

Super easy!

Widgetizing the Footer

Widgetizing the Footer

I really like this theme for WordPress and wanted something not so graphically intensive as Behemoth Gaming. However I wanted to add some widgets to the footer and this theme by default does not have a widgetized section.

Luckily for us that is easily solved. So how do you add a widget-ready section to your WordPress theme? Let’s show you how to do it!

The first thing I would recommend is make a child theme so that if your original theme gets updated your changes are not lost. But we aren’t covering that in this post so we will assume you either have a child theme or are confident you won’t overwrite your changes.

Using your choice of PHP editor (you can also easily do this from the Appearance Editor menu in WordPress if you wish) navigate to your functions.php file. What you are looking for in this file is some code that looks like “register_sidebar”. This tells your WordPress them what widget sections you have. In this theme the code I was looking for looked like this:

register_sidebar(array(
'id' => 'right-sidebar',
'name' =&gt; 'Right Sidebar',
'before_widget' => '<aside>',
'after_widget' => '</aside>',
'before_title' => '<h3>',
'after_title' => "</h3>",
));

This adds my sidebar so I can use the handy drag-and-drop widgets. In that same block of code (actually I did mine in my child theme but either way) I added this chunk of code which is very similar:

register_sidebar(array(
'name' => 'Footer',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

We have a couple options here. First is the name, which is the name of the widget section that we will be adding to the rest of our code in a minute. When you look to add widgets to this section, this is the name of the container as you drag them around.

The before_widget is any chunk of HTML you would like to be placed before your widget. As you can see, this is usually some opening tag but can also include anything you want. Want an image before every widget? You can do that too.

The other three options should be self-explanatory as well. These give you fairly robust control over the appearance of your widgets.

Now that we have defined the style and name of our widgetized section, we actually need to add the location for it to live within our template files. Within my footer.php I added the code:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Footer") ) : ?>
<?php endif; ?>

Widgetizing the Footer

Change the word “Footer” to whatever you named your new section in your functions.php file and save it. Provided all the code is correct you can now browse over to your Widgets menu and start adding!

Let me know if you have any problems or corrections!