Scenario: You have a custom post type archive page, and you want to be able to add some custom content to the archive without hardcoding it in the template. This is easy enough – you can create a page with the same name and slug, and set your templates to pull in the data from the page on the archive listing page by performing a query based on the post type slug.

However, it introduces a problem with the active state on the WordPress nav. You can create a custom nav item to point to the slug of the archive for your post type, but WP will see the nav item as referencing a page, even though you specified the item as custom.

In order to fix this behavior, you will need to filter the wp_get_nav_menu_items function to tell WP that the nav item is custom if it references a post type, which will force WP to match based on the URL and restore the active state to the nav:

I’ve started using PhpStorm for doing PHP development. So far, it’s been great. I find that I need to have significantly fewer programs and windows open, and that it automates a lot of the tasks I was doing manually.

Today, I puzzled out how to have PhpStorm invoke Grunt instead of running grunt watch in a terminal window:

Navigate to Project Settings > File Watchers.

Click + > Custom.

Name: Grunt.

Show console: Always.

Deselect Immediate File Synchronization.

File type: Any.

Scope: Click … button.

Click + and add a new scope – name it Grunt Watch, click OK.

Expand this window.

With your scope selected, browse in the file tree and select directories that Grunt would be watching and click Include Recursively.

Select files that Grunt is outputting (such as minified CSS and JS files) that you included in the previous step and click Exclude (this prevents the resulting output file from endlessly re-triggering Grunt execution).

Click OK.

Program: (browse to grunt executable path).

Working Directory: (browse to the directory that contains the Grunt file).