• Hello,
    I’m using the excelent theme features to build my site.
    I’m using the theme menu, that navigates over sections, and I’ve added an li on header.php menu builder to add a link to another page (so I won’t use only one page, the second page is a custom link to a product).

    <nav id="site-navigation" class="main-navigation" role="navigation" itemscope itemtype="https://schema.org/SiteNavigationElement">
    	<ul>
    	<?php 
    		if( ! get_theme_mod( 'business_one_page_ed_home_link' ) ){
    			
    			if( is_front_page() ){ ?>
    				<li class = "<?php echo esc_attr( 'current-menu-item', 'business-one-page' ); ?>"><a href="<?php echo esc_url( home_url( '#home' ) ); ?>"><?php echo esc_html( $home_link_label ); ?></a></li>
    			
    			<?php }else{ ?>
    				<li><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $home_link_label ); ?></a></li>
    	<?php   }
    		}
    		foreach( $enabled_sections as $section ){ 
    			if( $section['menu_text'] ){
    	?>
    			<li><a href="<?php echo esc_url( home_url( '#' . esc_attr( $section['id'] ) ) ); ?>"><?php echo esc_html( $section['menu_text'] );?></a></li>                        
    	<?php 
    			} 
    		}
    	?>
    			--mycustomlink <li id ="shopitem"><a href="https://site/product/custport1/">shop</a></li>
    	</ul>
    </nav>

    Everything works ok, I can navigate between my second page and the main page, but I cannot highlight the menu item of second page when I’m in.
    With wooks for wp_nav_menu I can’t reach beacuse the nav is not a standart one, so is there another way to get class .nav_menu_css_class assigned to my custom link like is done for sections?

    Thank you for your help

    Hugo

    • This topic was modified 4 years, 8 months ago by hugo2808.
    • This topic was modified 4 years, 8 months ago by hugo2808.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @hugo2808,

    I am sorry that I am not able to understand your question exactly.

    Can you please send me the screenshot of the issue that you are having with the CSS?

    Also, can you please post your site URL to understand the issue better.

    Thank you.

    Thread Starter hugo2808

    (@hugo2808)

    Hello,
    meanwhile I’ve already solved it.
    On the header I changed the code for nav to handle my external page css highligth when I’m on it.

    <nav id="site-navigation" class="main-navigation" role="navigation" itemscope itemtype="https://schema.org/SiteNavigationElement">
    	<ul>
    	<?php 
    		if( ! get_theme_mod( 'business_one_page_ed_home_link' ) ){
    			
    			if( is_front_page() ){ ?>
    				<li class = "<?php echo esc_attr( 'current-menu-item', 'business-one-page' ); ?>"><a href="<?php echo esc_url( home_url( '#home' ) ); ?>"><?php echo esc_html( $home_link_label ); ?></a></li>
    			
    			<?php }else{ ?>
    				<li><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $home_link_label ); ?></a></li>
    	<?php   }
    		}
    		foreach( $enabled_sections as $section ){ 
    			if( $section['menu_text'] ){
    	?>
    			<li><a href="<?php echo esc_url( home_url( '#' . esc_attr( $section['id'] ) ) ); ?>"><?php echo esc_html( $section['menu_text'] );?></a></li>                        
    	<?php 
    			} 
    		}
    	
    			if ( MY_PAGE_ID == get_queried_object_id() ) { $classes = 'class="current-menu-item"'; }
    	?>
    			<li <?php echo $classes ?>><a href="https://site/product/custport1/">shop</a></li>
    	</ul>
    </nav>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add External Link to OnePage Section Menu’ is closed to new replies.