Last active
May 24, 2020 12:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'), '©', esc_attr(date('Y')), esc_attr(get_bloginfo())); ?> | |
<span class="sep"> – </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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 | |
-------------------------------------------------------------- */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read more in the article: https://lorepirri.com/onepress-wp-theme-add-footer-menu.html