WordPress theme example 4

From Wiki @ Karl Jones dot com
Jump to: navigation, search

This page describes WordPress custom theme example four.

See all examples.

header.php

<!DOCTYPE html>
<html <?php language_attributes(); ?>>

    <head>
        <meta charset="<?php bloginfo( 'charset' ); ?>" />
		<meta name="HandheldFriendly" content="true">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="format-detection" content="telephone=no">
		<?php 
			$sep = ' | ';		// separator character
			
			if (is_page()) {
				$title = the_title ('','', false) . $sep . get_bloginfo( 'name' ) ;
			} else {
				$title = get_bloginfo( 'name' );
			}
		
		?>
        <title><?php echo $title; ?></title>
	
		
        <link rel="profile" href="http://gmpg.org/xfn/11" />
        <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" />
        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
        <?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
        <?php wp_head(); ?>
		<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
		<!--[if lt IE 9]>
		<link href="<?php echo get_template_directory_uri(); ?>/ie-lt-9.css" rel="stylesheet">
		<script src="<?php echo get_template_directory_uri(); ?>/js/css3-mediaqueries.js"></script>
		<script src="<?php echo get_template_directory_uri(); ?>/js/html5shiv.js" type="text/javascript"></script>
		<script src="<?php echo get_template_directory_uri(); ?>/js/respond.min.js" type="text/javascript"></script>
		<![endif]-->
	
    </head>
<?php
	$body_class='';
	
	if ( is_home() ) {
		echo "\r\n";
		echo '<!-- Home nav walker -->';
		echo "\r\n";
		$is_home = true;
		$body_class .= ' home';
	} else {
		echo "\r\n";
		echo '<!-- Non-Home nav walker -->';
		echo "\r\n";
		$is_home = false;
		$nav_home = '';
	}

?>	
	<body class="<?php echo $body_class; ?>">
		<header>	
 <nav class="navbar navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
				  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse" aria-expanded="false" aria-controls="navbar">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				  </button>
				  <div class="logo img-responsive"><a href="/"><img src="<?php echo get_template_directory_uri(); ?>/images/SourceGroup_Logo.png" alt="SourceGroup" /></a></div>
        </div>
      </div>
    </nav>
</header>	

<div>MGDP 2060:  Week 14</div>

functions.php

Like this:

<?php

/*

	This is an example of a simple functions.php file.

*/


// Require the Bootstrap NavWalker code be included here:

require_once ('wp_bootstrap_navwalker.php');

// Register Custom Navigation Walker

register_nav_menus( array(
    'primary' => __( 'Primary Menu', 'THEMENAME' ),
) );


function wpse87681_enqueue_custom_stylesheets() {
    if ( ! is_admin() ) {
        wp_enqueue_style( 'mytheme-custom', get_template_directory_uri() . '/more-styles.css' );
    }
}
add_action( 'wp_enqueue_scripts', 'wpse87681_enqueue_custom_stylesheets', 11 );

function karljones_enqueue_custom_stylesheets() {
    if ( ! is_admin() ) {
        wp_enqueue_style( 'myjs-custom', get_template_directory_uri() . '/js/custom-scripts.js' );
    }
}
add_action( 'wp_enqueue_scripts', 'karljones_enqueue_custom_stylesheets', 11 );