Browse Source

schema meta

windhamdavid 10 years ago
parent
commit
2d9764973c
4 changed files with 16 additions and 13 deletions
  1. 1 1
      header.php
  2. 11 8
      inc/template.php
  3. 1 1
      page-desk.php
  4. 3 3
      single.php

+ 1 - 1
header.php

@@ -9,7 +9,7 @@
 <meta charset="UTF-8" />
 <meta charset="UTF-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title><?php dw_page_title();?></title>
 <title><?php dw_page_title();?></title>
-<meta name="description" content="<?php dw_page_desc();?>"/>
+<meta name="description" content="<?php dw_meta_desc();?>"/>
 <?php wp_head(); ?>
 <?php wp_head(); ?>
 </head>
 </head>
 <body>
 <body>

+ 11 - 8
inc/template.php

@@ -12,16 +12,16 @@ function dw_page_title() {
 }
 }
 endif;
 endif;
 
 
-if ( ! function_exists( 'dw_page_desc') ) :
-function dw_page_desc() {
+if ( ! function_exists( 'dw_meta_desc') ) :
+function dw_meta_desc() {
 	global $post; 
 	global $post; 
 	$post = get_post( $post );
 	$post = get_post( $post );
 	setup_postdata( $post );
 	setup_postdata( $post );
-	$excerpt = dw_good_excerpt(115);
-	if (is_single()||is_page()){
-		if (get_post_meta($post->ID, "meta-desc", true) !='' ) 
-			echo get_post_meta($post->ID, "meta-desc", true); 
-		else echo $excerpt;
+	$meta_excerpt = dw_good_excerpt(115);
+	if ( is_single() || is_page() ) {
+		if ( get_post_meta($post->ID, 'meta-desc', true) ) {
+			echo get_post_meta($post->ID, 'meta-desc', true); 
+		} else $meta_excerpt;
 	}
 	}
 }
 }
 endif;
 endif;
@@ -38,8 +38,11 @@ function dw_good_excerpt($length) {
 	$text = strip_shortcodes($text);
 	$text = strip_shortcodes($text);
 	$text = strip_tags($text);
 	$text = strip_tags($text);
 	$text = substr($text,0,$length);
 	$text = substr($text,0,$length);
+	if ( strlen($text) < 10 ) {
+		$text = the_title('', ' - ', false);
+	}
 	$allowed_end = array('.', '!', '?', '...');
 	$allowed_end = array('.', '!', '?', '...');
-	$excerpt = reverse_strrchr($text, '.', 1);
+	$excerpt = reverse_strrchr($text, '.', 2);
 	if( $excerpt ) {
 	if( $excerpt ) {
 		echo apply_filters('get_the_excerpt',$excerpt);
 		echo apply_filters('get_the_excerpt',$excerpt);
 	} else {
 	} else {

+ 1 - 1
page-desk.php

@@ -13,7 +13,7 @@ get_header(); ?>
 			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 				<div class="entry-content">
 				<div class="entry-content">
 					<div class="date">
 					<div class="date">
-						<?php the_date('n/j/Y'); ?>		
+						<time datetime="<?php the_time('c');?>" itemprop="datePublished"><?php the_date('n/j/Y'); ?></time>		
 					</div>
 					</div>
 					<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'daw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
 					<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'daw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
 					<?php the_content(); ?>
 					<?php the_content(); ?>

+ 3 - 3
single.php

@@ -3,12 +3,12 @@
 	<div class="container">
 	<div class="container">
 		<article id="content" class="single" role="main">
 		<article id="content" class="single" role="main">
 			<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
 			<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
-			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+			<div itemscope="" itemtype="http://schema.org/BlogPosting" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 				<div class="entry-content">
 				<div class="entry-content">
 					<div class="date">
 					<div class="date">
-						<?php the_time('n/j/Y'); ?>	
+						<time datetime="<?php the_time('c');?>" itemprop="datePublished"><?php the_time('n/j/Y'); ?></time>
 					</div>
 					</div>
-					<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'daw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
+					<h2 itemprop="name headline" class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'daw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
 					<?php the_content(); ?>
 					<?php the_content(); ?>
 					<?php comments_template( '', true ); ?>
 					<?php comments_template( '', true ); ?>
 					<div class="clear">&nbsp;</div>
 					<div class="clear">&nbsp;</div>