page-loader page-loader page-loader
web logo

" Bir yolun yalnız yolcusu… "

hızmetler
X : / Kod / WordPress /

2023-01-11


WordPress Custom Theme Header

 logo

WordPress Custom Theme Header

WordPress Custom Theme Header. Bu yazımızda wordpress custom tema yaparken header kısmında kullanılan kod listesi bulunmaktadır. Bu kodlar ile header kısmını yapabilirsiniz.

Bu kod blogunda

  • wp gerekli html tag kodları
  • charset
  • header kodları
  • css js kodlar (isteğe bağlı)
  • body tag kodu
  • logo
  • slogan
  • header menü kodu

bulunmaktadır.

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<link rel="profile" href="http://gmpg.org/xfn/11">
	<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

	
	<?php wp_head(); ?>

	<?php echo '<link rel="stylesheet" href=" ' . get_bloginfo('template_directory') . '/style.css" rossorigin="anonymous" referrerpolicy="no-referrer" /> '?>
	
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" integrity="sha512-5A8nwdMOWrSz20fDsjczgUidUBR8liPYU+WymTZP1lmY9G6Oc7HlZv156XqnsgNUzTyMefFTcsFH/tnJE/+xBg==" crossorigin="anonymous" referrerpolicy="no-referrer" />

</head>

<body <?php body_class(); ?>>
<div class="hid">

<!-- ######################################################## -->

<header>

	<logo>
		
		<?php
			if ( function_exists( 'the_custom_logo' ) ) {
				the_custom_logo();
			}
		 ?>
	</logo>

	<div>
		<?php
				echo '<p>';
				bloginfo( 'description' );
				echo '</p>';
		 ?>
	</div>
	

<?php
    $header_menu = array(
		'theme_location' => 'header-menu',
		'fallback_cb'    => '__return_false',
        'before'     => '<span>',
        'after'      => '</span>',
        'container'       => false,
        'echo'            => false,
        'depth'           => 0,
    );
    if (has_nav_menu( 'header-menu' )) {
		echo '<nav id="header_nav"><div id="header_navbar_nav" class="navbar_nav" ><i class="fa fa-bars"></i></div>';
        echo strip_tags(wp_nav_menu( $header_menu ), '<a><span><div>' );
        echo '</nav>';
    }else{
    	echo '<hr>';
    }
?>
</header>


     if (has_nav_menu( 'header-menu' )) {

 		wp_nav_menu(array(
             'theme_location'    =>'blog-menu', // (string) Theme location to be used. Must be registered with register_nav_menu() in order to be selectable by the user.
             'container'         => 'div', // (string) Whether to wrap the ul, and what to wrap it with. Default 'div'.
             'container_id'		=> "", // (string) The ID that is applied to the container.
             'container_class'   =>'navbar-nav ms-auto py-0 nav ',  // (string) CSS class to use for the ul element which forms the menu. Default 'menu'.
             'items_wrap'        => '%3$s', // (string) How the list items should be wrapped. Default is a ul with an id and class. Uses printf() format with numbered placeholders.
             'before'			=> "", // (string) Text before the link markup.
             'after'				=> "", // (string) Text after the link markup.
             'link_before'		=> "", // (string) Text before the link text.
             'link_after'		=> "", // (string) Text after the link text.
         ));

     }else{
     	echo '<hr> ';
     }

 if (has_nav_menu( 'header-menu' )) {

     wp_nav_menu(array(
         'theme_location'    =>'blog-menu', // (string) Theme location to be used. Must be registered with register_nav_menu() in order to be selectable by the user.
          'items_wrap'        => '<ul id="%1$s" class="%2$s">%3$s</ul>', // (string) How the list items should be wrapped. Default is a ul with an id and class. Uses printf() format with numbered placeholders.
          'container_class'   =>'container-fluid',
          'menu_class'   =>'nav navbar-nav ',
          'depth' => 2,
          'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
          'walker'=> new wp_bootstrap_navwalker()
         ));

 }else{
     echo '<hr> ';
 }

WORDPRESS KONULARI


Okumak ilerlemenin bir parçasıdır.

– EW

YORUMLAR



Bir cevap yaz


E-posta hesabınız yayımlanmayacak. Gerekli alanlar işaretlendi *