0

I'm building a custom theme for my own portfolio and I'm just going to use the static menus I have in HTML template design.

Within this though I would like to add a function that sets the link address. I'm using the code below for the about page and it works, but is this the best way to do this? I'm new to custom themes so wanted to check in case there is a better, or "best-practice" way to do this.

Just to re-iterate I don't want to use dynamic menus linked to the backend menu controls.

Many thanks,

HTML / PHP

<li class="menu-item menu-item-1">
    <a href="<?php echo esc_url(home_url( '/about' ));?>">ABOUT</a>
</li>
0

If you're not using the default menu manager then already following a bad practice. Without using the menu manager you can create menu the way you're doing but I think get_permalink() will add some flexibility in this case or you can check the user contribution section of get_permalink(). There are some nice examples which might be helpful for you.

  • I'm don't think I am following bad practice by not using the backend. It's a different menu structure that I also want to make fully accessible on mobile with no JS. Doing it to the static file design means less code and headaches / issues / better performance. Thanks for the answer though. – The Chewy Mar 5 '18 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.