Forum Replies Created
-
AuthorPosts
-
August 14, 2017 at 8:41 pm in reply to: How to remove site footer wrap from bootstrap genesis theme #210373horace1Member
Thanks, I've added it to the function file but it still not working. What is it I'm doing wrong?
horace1MemberIm using the sample theme and this is just a test site which i have, hence why i am only using two nav items. All i want is to be able to display the logo in the top left like how you would see on a bootstrap nav so that i can use it in future projects.
I have inserted the following code below in to my functions.php which has helped display the actual menu but for some reason cant display the standard Genesis theme logo or dynamic text.
/** Integrating Bootstrap NAVs
*
* Tab and Pill navs require role='presentation' as an attribute to the- of a menu item
* Currently, there is no filter to add an attribute to the- (only added id or class)
* One way to do this would be to override the start_el function but seems like a lot of code to
* copy to only add an attribute. Created a simple jQuery solution in script.js.
*
* fixed-top and fixed-bottom require padding-top and padding-bottom, respectively. This is also
* added via jQuery in script.js since we can get the computed height of the nav and add the appropriate
* padding.
*/
//Menu variables:
//An admin interface could be created to change these values on the dashboard
$bfg_genesis_menu = false;
$bfg_menu_type = 'navbar'; //Possible values: tab, pill, navbar
$bfg_navbar_type = 'static-top'; //Possible values: static-top, fixed-top, fixed-bottom
$bfg_navbar_align = 'right';//
if (!$bfg_genesis_menu) {
//Take over nav
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
//TODO test adding subnav//Needed for all Bootstrap menus
add_filter('nav_menu_link_attributes', 'bfg_link_attributes',10,2);
add_filter('nav_menu_css_class', 'bfg_add_dropdown_active',10);
if ( $bfg_navbar_type === 'fixed-bottom' ) {
add_filter( 'body_class', 'bfg_fixed_bottom_body_class' );
}
if ( $bfg_navbar_type === 'fixed-top' ) {
add_filter( 'body_class', 'bfg_fixed_top_body_class' );
}//TODO add a admin user interface for these options.
//************Uncomment a single section to alter location of Primary Nav - Primary 1 thru 5//Primary 1***********Uncomment the following for Bootstrap primary nav replacing header*****************
//Genesis | Theme Settings | Header settings determines if nav_brand is shown or site_title is shown
// "Image Logo" will show nav_brand and site_title will be there but hidden
/* remove_action( 'genesis_header', 'genesis_do_header' ); //remove genesis header
add_action( 'genesis_header', 'bfg_custom_primary_do_nav', 5 );
add_filter('genesis_structural_wrap-header', 'bfg_no_wrap'); //remove structural wrap
add_filter('bfg_navbar_brand_content', 'bfg_navbar_brand_header'); //add brand*///Primary 2*********Uncomment the following for Bootstrap primary nav after Genesis Header****************
add_action( 'genesis_after_header', 'bfg_custom_primary_do_nav', 5 );//Primary 3*********Uncomment the following for Bootstrap primary nav before footer**********************
/* add_action( 'genesis_before_footer', 'bfg_custom_primary_do_nav'); *///Primary 4*********Uncomment the following for Bootstrap primary nav as footer**********************
/* remove_action('genesis_footer','genesis_do_footer');
add_action( 'genesis_footer', 'bfg_custom_primary_do_nav');
add_filter('genesis_structural_wrap-footer', 'bfg_no_wrap'); //remove structural wrap
add_filter('bfg_navbar_brand_content', 'bfg_navbar_brand'); //add brand*///Primary 5*********Uncomment the following for Bootstrap primary nav after Genesis Footer****************
/* add_action( 'genesis_after_footer', 'bfg_custom_primary_do_nav' );*/// Uncomment out if you want a search bar in the navbar
// add_filter('bfg_navbar_content', 'bfg_navbar_search_form');
}function bfg_fixed_bottom_body_class( $classes) {
$classes[] = 'fixed-bottom';
return $classes;
}
function bfg_fixed_top_body_class( $classes) {
$classes[] = 'fixed-top';
return $classes;
}/** Create primary nav using bootstrap. */
function bfg_custom_primary_do_nav() {
global $bfg_menu_type, $bfg_navbar_type, $bfg_navbar_align;//If menu has not been assigned to Primary Navigation, abort.
if ( ! has_nav_menu( 'primary' ) ) {
return;
}
//Default values
$container_class = '';
$menu_class = 'nav nav-pills';
$items_wrap = ' <div class="container-fluid"><ul id="%1$s" class="%2$s">%3$s</div>';
switch ( $bfg_menu_type ) {
case 'pill':
$menu_class = 'nav nav-pills';
$items_wrap = ' <div class="container-fluid"><ul id="%1$s" class="%2$s">%3$s</div>';
break;
case 'tab':
$menu_class = 'nav nav-tabs';
$items_wrap = ' <div class="container-fluid"><ul id="%1$s" class="%2$s">%3$s</div>';
break;
case 'navbar':
$container_class = 'navbar navbar-default navbar-' . sanitize_text_field( $bfg_navbar_type );
$menu_class = 'nav navbar-nav navbar-' . sanitize_text_field( $bfg_navbar_align );
$navbar_content = '';
$items_wrap = '<div class="container-fluid"><div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> ';
$items_wrap .= apply_filters( 'bfg_navbar_brand_content', $navbar_content ) . '</div> <div class="collapse navbar-collapse" id="navbar-collapse-1">';
$items_wrap .= apply_filters( 'bfg_navbar_content', $navbar_content ) . '<ul id="%1$s" class="%2$s">%3$s</div></div>';
break;
}wp_nav_menu( array(
'container' => 'nav',
'container_class' => $container_class,
'menu_class' => $menu_class,
'items_wrap' => $items_wrap,
'walker' => new bfg_Walker_Nav_Menu(),
'theme_location' => 'primary'
) );}
/** Extends the Walker_Nav_menu and overrides the start_lvl function to add class to sub-menu */
class bfg_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"sub-menu dropdown-menu\">\n";
}
}/** adds attributes to anchor, , of a dropdown menu */
function bfg_link_attributes($atts,$item) {
if(in_array('menu-item-has-children',$item->classes)) {
$atts["class"] = "dropdown-toggle";
$atts["data-toggle"] = "dropdown";
}
return $atts;
}
/** adds the necessary classes bootstrap expects for menu items,- , with children and current-menu-* items */
function bfg_add_dropdown_active($classes) {
if(in_array('menu-item-has-children',$classes) ){
$classes[] = 'dropdown';
}
if(in_array('current-menu-item',$classes) ){
$classes[] = 'active';
}
if(in_array('current-menu-parent',$classes) ){
$classes[] = 'active';
}
return $classes;
}
//TODO search submit button is slightly off of navbar-brand
//TODO need media query to change line-height when responsive menu is active
function bfg_navbar_search_form($navbar_content) {
$url = get_home_url();$navbar_content .= '<form method="get" class="navbar-form navbar-left" action="' . $url . '" role="search">';
$navbar_content .= '<div class="form-group">';
$navbar_content .= '<input class="form-control" name="s" placeholder="Search" type="text">';
$navbar_content .= '</div>';
$navbar_content .= '<button class="btn btn-default" value="Search" type="submit">Submit</button>';
$navbar_content .= '</form>';return $navbar_content;
}function bfg_navbar_brand($navbar_content) {
//TODO admin interface to add image, brand, url to options
$image = get_stylesheet_directory_uri() . 'images/logo.png';
list($width, $height, $type, $attr) = getimagesize($image);$url = get_home_url();
$brand = get_bloginfo('name');
$navbar_content .= '';
$navbar_content .= ' ';if ($height > 50) {
$navbar_content .= '<style> .navbar-nav li a, .navbar-form { line-height: ' . $height . 'px;}';
$navbar_content .= '.navbar-brand {height: inherit;}</style>';
}return $navbar_content;
}
function bfg_navbar_brand_header($navbar_content) {
//TODO admin interface to add image, brand, url to optionsob_start();
do_action('genesis_site_title');
$site_title = ob_get_contents();
ob_end_clean();
ob_start();
do_action('genesis_site_description');
$site_description = ob_get_contents();
ob_end_clean();$image = get_stylesheet_directory_uri() . 'images/logo.png';
list($width, $height, $type, $attr) = getimagesize($image);$url = get_home_url();
$brand = get_bloginfo('name');
$navbar_content .= '<div class="title-area">';$navbar_content .= ' ';
$navbar_content .= $site_title . $site_description . "</div>";
if ($height > 50) {
$navbar_content .= '<style> .header-image .navbar-nav li a, .header-image .navbar-form { line-height: ' . $height . 'px;}';
$navbar_content .= '.navbar-brand {display: none;} .header-image .navbar-brand {display: block; height: inherit;}';
$navbar_content .= '.</style>';
}return $navbar_content;
}function bfg_no_wrap($arg) {
return '';
}horace1MemberThanks it work
horace1MemberThanks,
I found a fallback from Bill Erickson
http://www.billerickson.net/code/svg-logo-png-fallback/
but I just ended up putting it like this
background: url(images/logo.png) no-repeat;
background-image: url(images/logo.svg), none;horace1MemberThanks so much, is there one which you could use from a background image as it was more for the logo i was trying to make a svg and then make a png in in the fallback.
February 24, 2017 at 4:38 pm in reply to: Hide Scripts ( Page-specific Scripts ) and Page attribute #201926horace1MemberThanks, I added this for post
remove_meta_box( 'genesis_inpost_scripts_box' , 'post' , 'normal' );
February 24, 2017 at 2:06 pm in reply to: Hide Scripts ( Page-specific Scripts ) and Page attribute #201918horace1MemberI found the code:
Remove the Page attribute meta data
=====================function remove_page_fields() {
remove_meta_box( 'pageparentdiv' , 'page' , 'normal' ); //removes page attributes
}
add_action( 'admin_menu' , 'remove_page_fields' );Remove Scripts
=====================remove_action( 'admin_menu', 'genesis_add_inpost_scripts_box' );
February 23, 2017 at 1:42 pm in reply to: Hide Scripts ( Page-specific Scripts ) and Page attribute #201844horace1MemberI'm wanting to remove or hide it from clients.
February 23, 2017 at 1:41 pm in reply to: Hide Scripts ( Page-specific Scripts ) and Page attribute #201843horace1MemberNo,I mean when like a client is logged into wordpress and they go to edit a page they see scripts at the bottom and page attribute to the right.
horace1MemberNo thats just one image, basically I want when you click on the logo its takes you the home page and when you click on the free consultation it takes you to the contact page. But i want i want it positioned like how it is in the image.
horace1MemberSorry think ive figured it out
horace1MemberOk thanks but how can i make it show a excerpt instead of the whole story and display thumbnails?
July 6, 2016 at 10:05 am in reply to: What is the best way to have a sticky navigation with the logo to the side #188960horace1Memberok thanks alot for that
- of a menu item
-
AuthorPosts