CPT template is not being automatically used single post pages

A few points.

  • Custom template files for single posts (not pages) within plugin directory normally needs an action filter, so, you must use it in your case.
  • Page templates are different then custom templates for any custom or built-in post type. To have page templates under Attributes etc. or in Astra, you need files like page-template1.php or page-template2.php having template header comments. Note that these are page templates, not post templates. In your case, to let the WP automatically pick your custom template for a custom post type from within your plugin directory, keep using the template action filter that you are already using.
  • In your template filter, you are matching post_type which is right, however, the value for it is wrong. Change Event Items to wppro-events in the action filter in line if ( $post->post_type == 'Event Items' ) and then check.
  • Still seeing old template? Flush the permalinks by saving permalinks for once under Admin Dashboard > Settings > Permalinks and then check again.

Let me know how it goes.

tech