Answer the question
In order to leave comments, you need to log in
Alternative to std. Wordpress templating engine?
Is there an alternative to the standard WP templating engine? For example, as in Modx or DLE.
I decided to try to make a WP template, the code turns out to be a bloody mess ... One menu styling is worth something, classes to add your own.
Answer the question
In order to leave comments, you need to log in
Maybe you don't know everything about wp codex functions.
Everything is very convenient in wp. And everything that is custom in functions.php
There are options, of course. For example, Blade from Laravel. Or Twig . And there are a few more, it seems even the Smarty port once caught my eye. But! If you haven’t figured out the native documentation and haven’t figured out how to customize the menu (which is actually very simple), then I assure you that in the documentation of these add-ons you will get confused and get bogged down even deeper. Just grab the native WordPress Codex and read, read, read.
For example, the task you mentioned of adding your class to the active menu item. First, it is already there, by default. These are the classes .current-cat or .current-page-item or .current-menu-item(current rubric, current page, or other current menu item). Secondly, if you want to add your own, so that it is called .active - please:
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
if( in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question