WordPress templates can be overridden to create a different layout of the content or to add additional content directly on the template. Usually plugins provide basic templates for their content which can be then overridden by themes. In this tutorial we will learn how you can override WordPress templates and even provide that option in your own plugin. Before we code our own override rules, we need to understand how WordPress works. The best thing you can do to understand it is to read the WordPress Template Hierarchy. Here is a simple explanation: User visit a single post WordPress looks for a template in the theme for that custom post type If there is no specific custom post type template defined it will use a general single post template If there is no single page template defined it will use the index.php What are those templates? A general single post template is single.php, or for a page is also page.php. For a custom post type, for example: Portfolio, which slug is portfolio the specific custom post type template would be single-portfolio.php. There can be templates defined by the slug of a post or page. We could have a page title Checkout which slug is checkout and the specific
Share This

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.