How to get dashes in post type/taxonomy slugs for URL SEO purposes

As of Custom Post Type UI version 1.13.2, this tutorial no longer applies. That release finalized allowing dashes in your content type slugs. Custom Post Type UI version 1.3.0 introduced JavaScript that enforces underscore characters in slugs. When a user tried to type a dash in the slug field, it gets automatically switched to an underscore. We have…

Read More

Creating an all term taxonomy archive

WordPress does not provide the easiest way to achieve post archives that have any term from a taxonomy. There is no functional URL that provides all the posts for a given taxonomy. WordPress does provideterm archives, but that is just one term at a time. If we’re blogging about mustards of the world, I don’t…

Read More

Changing posts per page for a post type

By default, post type archives inherit the same posts per page amount as the Reading settings page and the “Blog pages show at most” setting. However, depending on your use case, you may need to change that value just for a given post type. Utilizing the pre_get_posts action hook, you can easily modify the posts…

Read More

Save CPTUI settings data to file

If you ever find need to save your Custom Post Type UI settings data to a file, on top of to the database like normal, the following snippet should help you out. This will be particularly useful if you find need to version control the settings, as databases aren’t easy to version control themselves. What…

Read More

Displaying post type descriptions

Ever since post type creation became “public” in WordPress 3.0.0 in June 2010, users have been able to provide a description for their post type. However, for whatever reasons that the WordPress core team has, they have never provided an official way to retrieve that description value. Thankfully, the “get_post_type_object()” function provides that value for…

Read More

Cleanly-done pagination with custom WP_Query objects

If you have ever created a custom WP_Query object, chances are you have potentially needed to also provide pagination for the resulting loop and display of posts. Sadly, WordPress core does not make this the easiest to achieve, but it is possible depending on which pagination-based functions you use. This tutorial aims to show how…

Read More

Adding WordPress REST API support

The pending WordPress REST API has been a hot topic for WordPress developers and agencies for awhile now. While it’s true the endpoints are not presently merged into WordPress core, the framework needed to create endpoints are, making them able to be manually added by developers, coupled with having the REST API plugin installed and…

Read More

Adding post type posts to WP Nav Menus

If you want to add custom post type posts, you first need to make sure each desired post type is getting the necessary parameter. Once it is, you should see a section for it on the left side of the menu builder screen. Adding the support. When editing your post type, locate the “Show in…

Read More

How to add your new post type to WordPress category and tag archives

Out of the box, WordPress does not include custom post types in the archives for the default categories and tags archives. Because of this, you need to add the post types to the query yourself. You will add the following snippets to your theme’s functions.php file or if you want, to a custom plugin build…

Read More

Locating a post’s post ID

Often you will find functionality for your site that needs a post ID specified. This may be something provided by your current theme, or a plugin you have installed to manage certain tasks. The issue is that not all of them provide easy ways to look up the associated ID, and leave that up to…

Read More