Welcome! To use this support forum, please Login or Join Today!

   

How to replace Main Navigation Bar with Custom PHP

{name}
Rank

Total Posts: 2

Joined 2017-01-21

PM

 

Dear Casey,

I just bought a new plugin called Hero Menu and need to put the following code into the header, the primary menu especially;

<?php echo do_shortcode"[hmenu id=1]" ); ?> 

Can you help me with this?
Which of the following code should be replaced?

/*-----------------------------------------------------------------------------------*/
// 1.Header
/*-----------------------------------------------------------------------------------*/

if ( !function_exists'st_header_open' ) ) {

function st_header_open() {

 $class 
= (of_get_option('use_logo_image') ? "graphic" "text");

 echo 
"<div id=\"header\" class=\"$class\">\n";
 echo 
"\t<div class=\"container\">\n";
 echo 
"\t<div class=\"sixteen columns\">\n";

}

add_action
('st_header','st_header_open'1);


// endif


/*-----------------------------------------------------------------------------------*/
// 2.SEO Header/Logo Text
/*-----------------------------------------------------------------------------------*/


if ( !function_exists'st_logo' ) ) {

function st_logo() {

 
// Displays H1 or DIV based on whether we are on the home page or not (SEO)
 
$heading_tag = ( is_home() || is_front_page() ) ? 'h1' 'div';

 
// Apply a text or graphic class to the logo
 
if (of_get_option('use_logo_image')) {
  $class
="graphic";
 
else {
  $class
="text";
 
}

 
// Check to see if a custom title and tagline is defined
 
if (of_get_option('use_custom_titletag')) {
  $headline 
of_get_option('site_title');
  
$tagline =  of_get_option('site_tagline');
 
else {
  $headline 
get_bloginfo('name');
  
$tagline =  get_bloginfo('description');
 
}

 
// output the header
 
$st_logo  '<'.$heading_tag.' id="site-title" class="'.$class.'">';
 
$st_logo .= '<a href="'.esc_urlhome_url'/' ) ).'" title="'.esc_attrget_bloginfo('name','display')).'">';
 
$st_logo .= $headline;
 
$st_logo .= '</a></'.$heading_tag.'>'."\n";
 
$st_logo .= '<span class="site-desc '.$class.'">'.$tagline.'</span>'"\n";
 echo 
$st_logo;
}
add_action
('st_header','st_logo'2);

// endif


/*-----------------------------------------------------------------------------------*/
// 3.Main Navigation
/*-----------------------------------------------------------------------------------*/

if ( !function_exists'st_main_nav' ) ) {

 
function st_main_nav() {
  $menu_placement 
of_get_option('mainmenu_placement');

  echo 
'<div id="menu" class="'.$menu_placement.'">';
  if (
$menu_placement == 'below'{
   
echo '<div class="container">';
   echo 
'<div class="sixteen columns">';
  
}
  wp_nav_menu
( array( 'container_class' => 'menu-header''theme_location' => 'primary''menu_id' => 'nav'));
  if (
$menu_placement == 'below'{
   
echo '</div><!--/.columns row-->';
   echo 
'</div><!--/.container-->';
  
}
  
echo '<div class="clear"></div>';
  echo 
'</div><!--/#menu-->';
 
}
 add_action
'st_header''st_main_nav'3);

//endif 

Thank you.

{name}
RankRankRankRank

Total Posts: 3667

Joined 2011-04-27

PM

 

If you look in header.php you should see:

st_before_header();
st_header();
st_after_header(); 

You could try putting it in between one of those or hook straight into the st_header like so:

function myheromenu() {
 
echo do_shortcode"[hmenu id=1]" );
}
add_action
'st_header''myheromenu'3); 

(3 is the order in which the function will output)