seo.php文件完整代码公示!

原创 David  2021-11-27 15:58  阅读 459 次
>明月合作型SEO
网站系统开发,模板开发,常用的调用代码大全!
<?php if ( is_home() ) { ?><title><?php bloginfo('name'); ?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('description'); ?></title><?php } ?>
<?php if ( is_search() ) { ?><title>搜索结果<?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?>
<?php if ( is_single() ) { ?><title><?php echo trim(wp_title('',0)); ?><?php if (get_query_var('page')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('page'); echo '页';}?><?php if(get_option('ygj_titlecat')){echo stripslashes(get_option('ygj_lianjiefu'));foreach((get_the_category()) as $category){echo $category->cat_name;}}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?>
<?php if ( is_page() ) { ?><title><?php echo trim(wp_title('',0)); ?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?>
<?php if ( is_category() ) { ?><?php $categories = get_the_category(); $term_id = $categories[0]->term_id; $cat_name = $categories[0]->name; ?><?php } ?>
<?php if ( get_option( 'cat-title-'.$term_id )) : ?>
<?php if ( is_category() ) { ?><title><?php echo get_option( 'cat-title-'.$term_id ); ?><?php if (get_query_var('paged')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('paged'); echo '页';}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?>
<?php else: ?>
<?php if ( is_category() ) { ?><title><?php single_cat_title(); ?><?php if (get_query_var('paged')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('paged'); echo '页';}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?>
<?php endif; ?>
<?php if ( is_tag() ) { ?><?php $tag = get_the_tags(); $term_id = $tag[0]->term_id; $tag_name = $tag[0]->name; ?><?php } ?>
<?php if ( get_option( 'tag-title-'.$term_id )) : ?>
<?php if ( is_tag() ) { ?><title><?php echo get_option( 'tag-title-'.$term_id ); ?><?php if (get_query_var('paged')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('paged'); echo '页';}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?>
<?php else: ?>
<?php if (function_exists('is_tag')) { if ( is_tag() ) { ?><title><?php single_tag_title("", true); ?><?php if (get_query_var('paged')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('paged'); echo '页';}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?>明月PM</title><?php } ?><?php } ?>
<?php endif; ?>
<?php if ( is_year() ) { ?><title><?php the_time('Y年'); ?>所有文章<?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name'); ?></title><?php } ?>
<?php if ( is_month() ) { ?><title><?php the_time('F'); ?>份所有文章<?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name'); ?></title><?php } ?>
<?php if ( is_day() ) { ?><title><?php the_time('Y年n月j日'); ?>所有文章<?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name'); ?></title><?php } ?>
<?php if ( is_404() ) { ?><title>亲,你迷路了!<?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name'); ?></title><?php } ?>
<?php if ( is_tax('notice') ) { ?><title><?php setTitle(); ?> <?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name'); ?></title><?php } ?>
<?php
if (!function_exists('utf8Substr')) {
functionutf8Substr($str, $from, $len)
{
returnpreg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'$1',$str);
}
}
if ( is_single() ){
if ($post->post_excerpt) {
$description=$post->post_excerpt;
} else {
if(preg_match('/<p>(.*)<\/p>/iU',trim(strip_tags($post->post_content,"<p>")),$result)){
$post_content=$result['1'];
} else {
$post_content_r=explode("\n",trim(strip_tags($post->post_content)));
$post_content=$post_content_r['0'];
}
$description=utf8Substr($post_content,0,220);
}
$keywords="";
$tags=wp_get_post_tags($post->ID);
foreach ($tagsas$tag ) {
$keywords=$keywords.$tag->name.",";
}
}
?>
<?php echo "\n"; ?>
<?php if ( is_single() ) { ?>
<?php
if(get_option('ygj_xinghuo')){
date_default_timezone_set('PRC');
if(get_post_meta($post->ID, 'wzzz', true)){$copy=get_post_meta($post->ID, 'wzzz', true);}else{if(get_post_meta($post->ID, 'tgwz', true)){
$copy=get_the_author_meta( 'display_name',$post->post_author);}}?>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="<?php echo get_the_date('c');?>"/>
<?phpif (empty($copy)) {?>
<metaproperty="article:author"content="<?phpbloginfo('name');?>" />
<?php }else{ ?>
<metaproperty="article:author"content="<?phpecho$copy; ?>" />
<metaproperty="article:author"content="<?phpbloginfo('name');?>" />
<?php } ?>
<meta property="article:published_first" content="<?php bloginfo('name');?><?php echo ',';the_permalink();?>" />
<meta property="og:image" content="<?php if ( get_post_meta($post->ID, 'wzshow', true) ){echo get_post_meta($post->ID, 'wzshow', true); }else{echo catch_image();} ?>" />
<meta property="og:release_date" content="<?php echo get_the_date('c');?>"/>
<meta property="og:title" content="<?php echo trim(wp_title('',0)); ?><?php if (get_query_var('page')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('page'); echo '页';}?><?php if(get_option('ygj_titlecat')){echo stripslashes(get_option('ygj_lianjiefu'));foreach((get_the_category()) as $category){echo $category->cat_name;}}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name');?>" />
<?php if ( get_post_meta($post->ID, 'description', true) ) : ?>
<meta property="og:description" content="<?php $description = get_post_meta($post->ID, 'description', true);{echo $description;}?>" />
<?php else: ?>
<meta property="og:description" content="<?php echo trim($description); ?>" />
<?php endif; ?>
<?php } ?>
<?php if ( get_post_meta($post->ID, 'description', true) ) : ?>
<meta name="description" content="<?php $description = get_post_meta($post->ID, 'description', true);{echo $description;}?>" />
<?php else: ?>
<meta name="description" content="<?php echo trim($description); ?>" />
<?php endif; ?>
<?php if ( get_post_meta($post->ID, 'keywords', true) ) : ?>
<meta name="keywords" content="<?php $keywords = get_post_meta($post->ID, 'keywords', true);{echo $keywords;}?>" />
<?php else: ?>
<meta name="keywords" content="<?php echo trim($keywords,','); ?>,<?php foreach((get_the_category()) as $category){echo $category->cat_name;}?>" />
<?php endif; ?>
<?php } ?>
<?php if ( is_page() ) { date_default_timezone_set('PRC');?>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="<?php echo get_the_date('c');?>"/>
<metaproperty="article:author"content="<?phpbloginfo('name');?>" />
<meta property="article:published_first" content="<?php bloginfo('name');?><?php echo ',';the_permalink();?>" />
<meta property="og:image" content="<?php if ( get_post_meta($post->ID, 'wzshow', true) ){echo get_post_meta($post->ID, 'wzshow', true); }else{echo catch_image();} ?>" />
<meta property="og:release_date" content="<?php echo get_the_date('c');?>"/>
<meta property="og:title" content="<?php echo trim(wp_title('',0)); ?><?php if (get_query_var('page')) { echo stripslashes(get_option('ygj_lianjiefu'));echo '第'; echo get_query_var('page'); echo '页';}?><?php echo stripslashes(get_option('ygj_lianjiefu')); ?><?php bloginfo('name');?>" />
<meta property="og:description" content="<?php $description = get_post_meta($post->ID, 'description', true);{echo $description;}?>" />
<meta name="description" content="<?php $description = get_post_meta($post->ID, 'description', true);{echo $description;}?>" />
<meta name="keywords" content="<?php $keywords = get_post_meta($post->ID, 'keywords', true);{echo $keywords;}?>" />
<?php } ?>
<?php if ( is_category() ) { ?>
<meta name="description" content="<?php echo category_description( $categoryID ); ?>" />
<?php if ( get_option( 'cat-words-'.$term_id )) : ?>
<meta name="keywords" content="<?php echo get_option( 'cat-words-'.$term_id ); ?>" />
<?php else: ?>
<meta name="keywords" content="<?php single_cat_title(); ?>" />
<?php endif; ?>
<?php } ?>
<?php if ( is_tag() ) { $tag_description=tag_description();?>
<?php if ( empty($tag_description)) : ?>
<meta name="description" content="『<?php echo single_tag_title(); ?>』标签的相关文章" />
<?php else: ?>
<meta name="description" content="<?php echo trim(strip_tags(tag_description())); ?>" />
<?php endif; ?>
<?php if ( get_option( 'tag-words-'.$term_id )) : ?>
<meta name="keywords" content="<?php echo get_option( 'tag-words-'.$term_id ); ?>" />
<?php else: ?>
<meta name="keywords" content="<?php echo single_tag_title(); ?>" />
<?php endif; ?>
<?php } ?>
<?php if ( is_home() ) { ?>
<meta name="description" content="<?php echo get_option('ygj_description'); ?>" />
<meta name="keywords" content="<?php echo get_option('ygj_keywords'); ?>" />
<?php } ?>
本文地址:https://www.rrdsyy.com/1822.html
关注我们:请关注一下我们的微信公众号:扫描二维码 号名称暂无
版权声明:本文为原创文章,版权归 明月SEO 所有,欢迎分享本文,转载请保留出处!
西安网站制作

发表评论


表情