From the course: WordPress: Custom Post Types and Taxonomies

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Automatically flushing rewrite riles

Automatically flushing rewrite riles - WordPress Tutorial

From the course: WordPress: Custom Post Types and Taxonomies

Start my 1-month free trial

Automatically flushing rewrite riles

- [Instructor] So far, we've seen the manual way to flush rewrite rules by going to settings, permalinks. And as you saw, that can be a tedious process. If you forget, it can cause unnecessary headache for troubleshooting. And you need to do it anytime you make a change to the URL or rewrite structure. So, let's see how we can flush rewrite rules automatically with our plugin and our child theme. Here on the screen, you see the codex page for register post type. If you scroll towards the bottom, you'll see the flushing rewrite on activation. And it gives you sample code to use in both your plugin and your theme. We're going to copy this first block of text here, this first block of code, and we're going to paste it into our plugin. So, let's go to our plugins to LIL-postypes.php. And at the bottom, below the other add actions, we'll paste this code. We'll clean it up a little bit. We'll get rid of the cautionary comments, though they are very important to read. Now, you should only do…

Contents