Skip to content

Instantly share code, notes, and snippets.

@lorepirri
Last active May 24, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorepirri/e887aa37a060a7d2691b3c2cc730c8dc to your computer and use it in GitHub Desktop.
Save lorepirri/e887aa37a060a7d2691b3c2cc730c8dc to your computer and use it in GitHub Desktop.
How to add a menu in the footer of OnePress WordPress Theme via child theme
<?php
/**
* OnePress Child Theme Functions
*
*/
/**
* Enqueue child theme style
*/
add_action( 'wp_enqueue_scripts', 'onepress_child_enqueue_styles', 15 );
function onepress_child_enqueue_styles() {
wp_enqueue_style( 'onepress-child-style', get_stylesheet_directory_uri() . '/style.css' );
}
// !!! Replace everywhere 'onepress-child' with your Text Domain's theme
// if you have changed it in your child theme (see style.css header).
function wp_custom_new_menu() {
// Add two menus: this theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'onepress-child' ),
'secondary' => __('Secondary Navigation', 'onepress-child')
) );
}
add_action( 'init', 'wp_custom_new_menu' );
// Customize the footer area (show also the secondary menu)
if ( ! function_exists( 'onepress_footer_site_info' ) ) {
/**
* Add Copyright and Credit text to footer
* @since 1.1.3
*/
function onepress_footer_site_info()
{
?>
<!-- shows our custom menu -->
<?php if( has_nav_menu( 'secondary', 'onepress-child' ) ) {
?> <div class="footer-menu-container"> <?php
wp_nav_menu( array( 'theme_location' => 'secondary' ) );
?> </div> <?php
} ?>
<!-- end: shows our custom menu -->
<?php printf(esc_html__('Copyright %1$s %2$s %3$s', 'onepress'), '&copy;', esc_attr(date('Y')), esc_attr(get_bloginfo())); ?>
<span class="sep"> &ndash; </span>
<?php printf(esc_html__('%1$s theme by %2$s', 'onepress'), '<a href="' . esc_url('https://www.famethemes.com/themes/onepress', 'onepress') . '">OnePress</a>', 'FameThemes'); ?>
<?php
}
}
/*
Theme Name: OnePress Child
Theme URI: https://www.famethemes.com
Description: OnePress sample child theme
Author: FameThemes
Author URI: https://www.famethemes.com
Template: onepress
Version: 1.0.0
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: onepress-child
*/
/* Styles for the custom footer menu
-------------------------------------------------------------- */
.footer-menu-container { display: block; width:100%; margin-bottom: 12px; }
.footer-menu-container ul { display: inline; padding-left: 0px; }
.footer-menu-container li { list-style-type: none; display: inline; }
.footer-menu-container li:before {
content: "\007C";
font-family: FontAwesome;
margin-left: 6px;
margin-right: 8px;
}
.footer-menu-container li:first-of-type:before {
content: none;
margin-right: 0;
}
.footer-menu-container li:last-of-type {
margin-right: 0;
}
/* Add your custom css below
-------------------------------------------------------------- */
@lorepirri
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment