Custom post types, taxonomies, and permalinks

Change slug in your post type arguments to products/%product_cat%, and slug in your taxonomy arguments to just products, then flush your rewrite rules. WordPress should now handle /products/my-product-cat/post-name/! Now finally, we need to help WordPress a little with generating permalinks (out of the box, it won’t recognise the permastruct tag %product_cat%): /** * Inject term … Read more

How to disable the single view for a custom post type?

METHOD 1: Redirect to a custom URL for single view, archive page is still publicly accessible. You can use template_redirect hook to redirect for a custom post type, you can use any other URL you want to in place of home_url() and the error code in other argument. <?php add_action( ‘template_redirect’, ‘wpse_128636_redirect_post’ ); function wpse_128636_redirect_post() … Read more

Where to put my code: plugin or functions.php?

I would start with this question: Is the functionality related to presentation of content, or with generation/management of content, or of the site, or of the user identity? If the functionality is not related specifically to presentation of content, then it is squarely within Plugin Territory. This list is long: Modifying core WP filters (wp_head … Read more