How to customize file path for 404 redirection in php?

This should work for you, using plugins_url(): … // Assumes that your templates are in a subdirectory called ‘templates’ in your plugin. // Adjust accordingly. $templates_dir = plugins_url( ‘templates’, __FILE__ ); $page_404 = $templates_dir . ‘/404-‘ . $post_type . ‘.php’ ); … Update: template_include If you want to have WordPress loaded up, you might be … Read more

How can I get custom post types to recognize pretty permalink variables?

Building Custom URLs in WordPress discusses how to use Pretty Permalinks to display posts using additional parameters. Jump to the section on Custom Query Vars. That’s where your situation begins to be addressed directly. In particular, you may want to use the example using ‘pre_get_posts‘ to retrieve parameters and adjust the WP_Query using a meta_query, … Read more