Customize Tortuga WP theme

Customizing Tortuga free WordPress theme

I love Tortuga theme, and I am using it for this site.

In this post, I will give some tips on ho to make it even better.

The first thing I did was changing footer text without removing do_action in the footer.php file. I managed to override the function in my child theme.

Changing footer text in Tortuga theme

I had trouble changing footer text (copyright) to suit my needs without removing do_action in the footer.php file.

tortuga_footer_text action is located in tortuga/inc/template-tags.php file that is required from parent theme’s functions.php using get_template_directory() function instead of get_stylesheet_directory()

The problem

This is the problem #1 as you can’t just copy this file, modify it and upload it in your child theme directory as parent theme’s template-tags.php file will still be used instead.

You have to require this copied template-tags.php file in your child theme’s functions.php file. However, this is when problem #2 arises. If you require this file, you will get an error as function tortuga_footer_text gets declared two times. First in child theme’s template-tags.php file and then again in parent theme’s template-tags.php file

It’s because functions.php file from child theme doesn’t override parent theme’s functions.php file. Instead, it just loads first.

This problem would have been easily avoided by the theme developers if

a) they used get_stylesheet_directory() function when they required template-tags.php file or

b) wrapped this tortuga_footer_text action from the template-tags.php inside of the following code as they did with all of the other functions,

if ( ! function_exists( 'tortuga_footer_text' ) ) : /*function here*/ endif;

The solution

Obviously, you could utilize one of the solutions above on your own and modify the parent theme, but that is not the best practice. Child themes are meant to prevent custom modifications getting wiped whenever parent theme is updated. Hence I propose two solutions:

Solution #1 – forget about the template-tags.php file and modify the footer.php template. Just erase do_action( 'tortuga_footer_text' ); line and insert your html. Insert your code inside tags to get the same styling as the original theme if you wish.

This solution has a limitation as you won’t have an easy access for changing all of the other functions declared in template-tags.php file. Below is the recommended solution.



Solution #2 – Copy the template-tags.php file to your child theme folder. Modify the tortuga_footer_text function; just replace tortuga with your child-theme name and then change this newly created function as you wish.

Example:


function child_theme_footer_text() {
?>
<span class="credit-link">
<?php echo 'Copyright &copy; 2016 <a href="/">MyChildTheme</a>'; ?>
</span>
<?php
}
add_action( 'child_theme_footer_text', 'child_theme_footer_text' );

After this step, you should be okay to require this newly created template-tags.php file in your child theme’s functions.php file like this:

require get_stylesheet_directory() . '/inc/template-tags.php';

The last step is to modify the footer.php file. Just replace the

<?php do_action( 'tortuga_footer_text' ); ?>

with

<?php do_action( 'child_theme_footer_text' ); ?>

Hope this tip helps if you are running beautiful Tortuga theme as well as the other themes that may have given you headaches with requiring template-tags.php file inside child theme’s functions.php file.

Adding footer menu

In Tortuga theme’s footer, there is a do_action function called learnedia_footer_menu, but there was no footer menu available. Instead, you have to register new menu in your functions.php file. This is how you do it:

 function register_menu() {
    register_nav_menu('footer-menu', __('Footer Menu'));
}
add_action('init', 'register_menu');
add_action ('learnedia_footer_menu', 'learnedia_footer_menu' );
function learnedia_footer_menu(){
    if ( has_nav_menu( 'footer-menu' ) ) { 
          wp_nav_menu( array( 'theme_location' => 'footer-menu') ); 
    }
}

Place the above code in your functions.php file. You can change the function name to a whatever unique name you choose. You just have to make sure to call the right function in child theme’s footer.php file.

So, in my example, I would modify the line to look like this:

<?php do_action( 'learnedia_footer_menu' ); ?>

Now you can create your Footer Menu in the admin dashboard and check it out in action.

Adding some margin to previous and next post links

One thing I didn’t like in the post design is no breathing room for the previous and next post links. Check out the screen shot of the entry footer before the changes I made to the Tortuga child theme.Tortuga entry footer beforeFortunately, this can be solved easily. Just add the following CSS to the style.css file in the child theme of the Tortuga theme:

.entry-footer {
margin-top: 35px;
}

The result:

Tortuga entry footer after

Obviously, you can change the value of margin-top to whatever you want; I am happy with 35px.

If you have any further questions about how to customize your Tortuga theme based website, please contact me or comment below or go through official Tortuga theme docs. Thanks for reading.

3 comments

Leave a Reply

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