Whoa Nellie! To get the most out of this lesson, you should have a passing familiarity with PHP and be comfortable editing text files on your site.


For this lesson, we will show you how to change the location of the main navigation bar.  Let’s look at the header area on the BluePrint-Q website.  In this case, we use two pieces – the masthead and the navigation bar.

Delving into code

In your IDE, navigate to bpq/hooks/bpq.hook.wordpress.php.  In there, you’ll see a series of actions related to the frame.  Take note on the highlighted lines – that’s what we care most about for this exercise.

Both lines subscribe to the action_bpq_header hook.  One action displays the masthead, the other displays the navigation bar.  The third argument is an integer.  The lower the integer value, the earlier that component is displayed.  Because the masthead is associated with 200 and the navigation bar is associated with 300, the masthead is displayed before the navigation bar.  Let’s look at changing that.

Navigate to the functions.php file in your child theme.  You are going to remove the action that the parent theme has set up for displaying the navigation bar and replace it so that it is triggered before the masthead.

There is a slight caveat here – because of the way that WordPress processes child and parent theme relationships, you must specially trigger your hook-changing code.  Paste the following code into your child-theme’s functions.php file.

Notice that you are removing the navigation bar action from the parent and replacing it with the same function call, but at an earlier priority – a priority that comes before 200, as indicated by the masthead hook in the parent theme.

Final result

Here is what the header now looks like.  Voila!