(+84) 463.28.7979

How to center align menu – Thesis theme for wordpress


I have been customizing Thesis for one of my client when he requested me to center align the menu. the I searched through many website and blog and found no perfect solution. Though I found some solutions but none was perfect. Before I tell you how to center align menu in Thesis, I would like to thank Atahualpa theme developers because the following code is actually used in Atahualpa for centering menus. I just implemented it in Thesis.

How to center align menu in Thesis

The code is too simple. You are just required to add the following code intocustom_functions.php file of your Thesis theme. No extra CSS code is required. This method plays very well with the menu as well with the submenus.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
function my_nav_menu()
{
?>
<div id="menuwrap">
<table cellspacing="0" cellpadding="0" style="margin: 0pt auto;"><tbody><tr><td align="center">
<?php thesis_nav_menu(); ?>
</td></tr></tbody></table>
</div>
<?php
}
remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_after_header', 'my_nav_menu');
?>

Note – I also moved the menu below header image. If you want to keep the menu above the menu header then replace the last line of the code i.e

1
add_action('thesis_hook_after_header', 'my_nav_menu');
with
1
add_action('thesis_hook_before_header', 'my_nav_menu');

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>