Filter and modify a Custom Post Type – after it’s been registered

Today I was tasked with adding functionality to an existing custom post type. The problem was, the CPT was being registered in a plugin which I could not edit (client declined to give WDS write access to the /plugins folder).

After some digging, I found there’s a filter for that (found in post.php) which allows you to modify a custom post type (after it’s been registered some other way) and could do so in the theme.

apply_filters( 'register_post_type_args', $args, $post_type );

Hooking into that filter, allowed me to pass additional options to an existing CPT:

Now “Products” has an archive, along with some other meta boxes in the post editor. Nice!

Filter and clean the Archive Title

This client wanted to feature their archive titles in a large hero area. The PSD excluded the prefixes like, “Category:”, “Tag:”, “Author:”, etc…

The snippet below allows you to strip out the prefixes used in the get_the_archive_title(); function, as well as any HTML tags.

Screenshot of the clean archive title
Screenshot of the “clean” archive title.

Jeremy Pry helped me solve this by inserting this regular expression into PHP’s preg_replace();  function. It executes a find and replace on the $title variable.

2015-2016 Alabama Hunting Seasons

Below are the 2015-2016 Alabama hunting season dates. Dates are valid through August 31st, 2016. Consolidated information provided by both outdooralabama.com and eregulations.com. Check out the 2015-2016 Hunting & Fishing Digest (35MB .pdf) – which contains this years requirements, fees, and season dates.

Why? Because the DNR makes this information hard to find. It’s scattered across the 76 page Hunting & Fishing Advertisement Digest and all over the web. I hope you found this page helpful. Good luck out there – and be safe! Happy hunting!

Continue reading “2015-2016 Alabama Hunting Seasons”