Adding a “My Home” menu item to your navigation menu
On the CBOX Community forum @Sam asked us the following question:
Is there any way to add a ‘My Home’ tab in the main menu that would take logged in members back to their own profile page
This short tutorial will show you exactly how this can be done.
Step 1: Download and Install your CBOX Child Theme
When you make customisations to your CBOX theme you always do this through a so called Child Theme. We’ve written a simple tutorial on how to download and install a pre-made Child Theme.
Step 2: Make some changes to your Child Theme
Using a FTP client of your choice you now need to open up the following file: cbox-child/engine/includes/custom.php
Once you have that file opened add the following snippet after the opening php tags:
That’s it! Save your changes to the file.
Step 4: Check out the results
Do a hard refresh of your website and you should now see the following in your main menu:
Bonus Tip: Showing the My Home item in different menus
Do you want to show the “My Home” in a different CBOX menu then the Main Menu? All you need to do is make a small change to the code snippet. On line 7 of the snippet change the following:
if ($args->theme_location == 'main-menu') {
into
if ($args->theme_location == 'over-menu') {
to show it in the Top Menu.
Want to change it into the Sub Menu? Change it to:
if ($args->theme_location == 'sub-menu') {
Done 🙂
Want to learn more about developing with CBOX?
If you are a theme developer I strongly advise you to take a look at our Theme Developers guide which contains all you need to know about how to create your own custom CBOX themes!
Have fun!
Hmmm…in my Cbox child theme, I see only three files: rtl.css, style.css, and screenshot.png.
There is no /engine file, (and thus no engine/includes/custom.php , either).
In the main Cbox theme, there is a path to engine/includes/ , but there’s no custom.php file.
Two or three questions:
1) Is my child theme supposed to include all of the parent theme’s files?
2) Am I supposed to create the custom.php file (and if so, where?)?
Thank you!
Clearly, I don’t know what I’m doing–but I’m trying! 😉
I created the missing file structure in the child theme. But the custom.php file is blank, so pasting the code snippet into the file isn’t going to do anything.
Were the /engine and /includes directories and the /custom.php file already supposed to be there in the child theme?
And what is the custom.php file supposed to have in it before I paste the snippet in? I can’t find it elsewhere in the parent theme’s files.
Thank you!
–Melynda
@melynda – When you create
/engine/includes/custom.php
, make sure you have opening PHP tags so yourcustom.php
file looks like this:http://pastebin.com/qJTB6m1U
Hope that helps!