建站笔记(续更~)

Published in Nov-14-2017


文章目录

   
因为是强迫症患者,所以在写这个网站的时候,总觉得不顺眼,所以一直都是改改改,特别是对一下小细节方面,如文字间距、行距,字体被选中时的颜色和背景颜色,点击a标签时出现的虚线边框等等….这里就记录一下这些小细节的代码,原因呢,主要是怕一觉醒来都忘记了。

#style.css

-webkit-tap-highlight-color:none; -webkit-tap-highlight-color:transparent;/*解决手机端a、img标签点击事件时的出现遮罩或闪屏问题*/

//选中的字体颜色和背景颜色 ::selection {color:#ffffff;background-color:#0085a1;} ::-moz-selection {color:#fffff;background-color:#0085a1;}

//取消a标签点击后的虚线框 a:focus { outline:none; -moz-outline:none; }

position: absolute;left: 左边距;top:上边距 ;/*直接对元素定位*/

textarea::-webkit-input-placeholder { }/*输入框内的显示文字样式*/

overflow:hidden;/*一是隐藏溢出,二是解决当height:auto时,背景颜色和背景图片不能显示*/

letter-spacing:0.08rem;/*字间距*/ 

outline:none;/*去除input点击时出现的边框*/

vertical-align:middle;/*把此元素放置在父元素垂直居中*/

.icon img:hover{/*transform: scale(1.2,1.2);/*X轴,Y轴为原来的几倍*//*transform: rotateZ(360deg);鼠标经过图片旋转*/}

#WordPress

控制文章文章摘要字数,在functions.php内加入如下代码

<?php
function new_excerpt_length($length) {
    return 135;/*文章摘要字数控制*/
}
add_filter('excerpt_length', 'new_excerpt_length');
?>

评论回复添加@评论人,在functions.php内加入如下代码

// 评论添加@
function ludou_comment_add_at( $comment_text, $comment = '') {
  if( $comment->comment_parent > 0) {
    $comment_text = '@<a class="depth-name" href="#comment-' . $comment->comment_parent . '">'.get_comment_author( $comment->comment_parent ) . '</a> ' . $comment_text;
  }

  return $comment_text;
}
add_filter( 'comment_text' , 'ludou_comment_add_at', 20, 2);

开启wordpress友情链接管理

先在functions.php内加入如下代码

//开启wordpress友情链接管理
add_filter( 'pre_option_link_manager_enabled', '__return_true' );

   
然后在页面位置加入如下代码

	<!--友情链接-->
	<ul class="friends">
	<h5>FRIENDS</h5>
<?php $resul = $wpdb->get_results("SELECT link_ID,link_url,link_name,link_description FROM $wpdb->links where link_visible ='y' ORDER BY rand() LIMIT 0 , 10");
      foreach ($resul as $links) {
      setup_postdata($links);
      $linkid = $links->link_ID;
      $linkurl = $links->link_url;
      $linkname = $links->link_name;
      $linkdescription  = $links->link_description 
?>
      <li ><a  href="<?php echo $linkurl ?>" target=”_blank” title="<?php echo $linkdescription ?>"c><?php echo ( $linkname); ?></a></li> 
<?php } ?>    		
     </ul>
      <!--友情链接-->

使WordPress支持post thumbnail(特色图片)

先在functions.php内加入如下代码

//使WordPress支持post thumbnail(特色图片)

add_theme_support( 'post-thumbnails' );

然后在页面位置加入以下代码

<?php if ( has_post_thumbnail() ) { ?> <?php the_post_thumbnail(); ?> <?php } else {?> <img src="<?php bloginfo('template_url'); ?>图片地址//如果没有设置图片则调用这张图片" alt="特色图片" /> <?php } ?>

全站301跳转到https,在.htaccess内加入如下代码

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R=301]



评论

正在获取,请稍候...
00:00/00:00