Search for Resources and Solutions

How to use the code which should be used in more theme's files

I'm speaking about such kind of code as menu, footer, header, sidebar. You can't put the code in all files where you need. Midrub has a feature, called parts which allows to work with this kind of the code. 

So, how the parts works? Create a directory in your theme contents/parts and put there files with code which should be used in more files. After this, use the function get_theme_part to include the file. 

How the function get_theme_part works? Supposing you have the file menu.php and header.php, you just have to write this code:

  • get_theme_part('menu') - to include the menu.php
  • get_theme_part('header') - to include the header.php

 With get_theme_part you can easy create a professional theme for Midrub Frontend. 

Was this article helpful?