php – Plugin for wordpress as a separate page with its own layout



There is a WP site for which I need to write a plugin. The task is as follows:

  1. There is a menu section that has its own submenu, i.e. two-level dropdown, and the second level needs to be brought out dynamically from the base.
  2. Information from the database using the links of the above menu should be displayed on a separate page with its own layout. That is, something like this: I click the link, the data is sent to POST or the URL is parsed and this page displays dynamic content.

Question: how to implement this functionality using a plugin so that you can fit into the design of an existing site? Is this possible for WP in principle?



If there is no need to arrange it in the form of a plugin, then you can do it like this:

  1. Create a PHP file in the template folder with an arbitrary name and the functionality you need. For instance,

     <?php /* Template Name: Hello-Tpl */ // этот комментарий позволяет увидеть файл в списке шаблонов для страницы get_header(); // для работы в шаблоне сайта echo 'Hello world!'; // ваш функционал get_footer(); // для работы в шаблоне сайта ?>
  2. Create a new page by selecting in the "Attributes-> Template" block the name of your template (the first line of the comment): "Hello-Tpl"
Scroll to Top