Browse Source

schema meta

windhamdavid 5 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 name="viewport" content="width=device-width, initial-scale=1">
 <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(); ?>
 </head>
 <body>

+ 11 - 8
inc/template.php

@@ -12,16 +12,16 @@ function dw_page_title() {
 }
 endif;
 
-if ( ! function_exists( 'dw_page_desc') ) :
-function dw_page_desc() {
+if ( ! function_exists( 'dw_meta_desc') ) :
+function dw_meta_desc() {
 	global $post; 
 	$post = get_post( $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;
@@ -38,8 +38,11 @@ function dw_good_excerpt($length) {
 	$text = strip_shortcodes($text);
 	$text = strip_tags($text);
 	$text = substr($text,0,$length);
+	if ( strlen($text) < 10 ) {
+		$text = the_title('', ' - ', false);
+	}
 	$allowed_end = array('.', '!', '?', '...');
-	$excerpt = reverse_strrchr($text, '.', 1);
+	$excerpt = reverse_strrchr($text, '.', 2);
 	if( $excerpt ) {
 		echo apply_filters('get_the_excerpt',$excerpt);
 	} else {

+ 1 - 1
page-desk.php

@@ -13,7 +13,7 @@ get_header(); ?>
 			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 				<div class="entry-content">
 					<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>
 					<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(); ?>

+ 3 - 3
single.php

@@ -3,12 +3,12 @@
 	<div class="container">
 		<article id="content" class="single" role="main">
 			<?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="date">
-						<?php the_time('n/j/Y'); ?>	
+						<time datetime="<?php the_time('c');?>" itemprop="datePublished"><?php the_time('n/j/Y'); ?></time>
 					</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 comments_template( '', true ); ?>
 					<div class="clear">&nbsp;</div>