1、首先对主题的宽度进行了调整,感觉原来的主题太窄了。2016-12-19
对style.css进行几个宽度定义进行了修改,(用开发者工具进行演示修改来确定最终宽度)。
2、对标签云进行修改,原来的标签云感觉不美观。 2016-12-19
修改WordPress标签字体大小:
在cpanel面板中依次打开「wp-includes」→「category-template.php」,找到wp_tag_cloud,(此文件为WP程序文件,更新后可能丢失设置)
function wp_tag_cloud( $args = ” ) { $defaults = array( ‘smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45, ‘format’ => ‘flat’, ‘separator’ => “\n”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘exclude’ => ”, ‘include’ => ”, ‘link’ => ‘view’, ‘taxonomy’ => ‘post_tag’, ‘echo’ => true ); $args = wp_parse_args( $args, $defaults );
其中:
smallest:使用次数最少的标签字号大小,默认是「8」;
largest:使用次数最多的标签字号大小,默认是「22」;
其实网上很多教程对smallest和largest讲的都不准确,网上都说的是smallest表示标签字体最小字号,largest表示标签字体最大字 号,所以最开始的时候我只写了一篇文章,当然标签的使用次数都是1次,所以标签的大小都是一样的,当时我还没理解到为什么标签的大小都一样呢
unit:标签字体大小单位,默认是「pt」;字体不受控可将此改为[px]
number:标签云中显示标签的数量,默认是「45」;
format :「Flat」怎么个显示法没搞懂;
separator:标签之间的分隔符,默认是空格;
orderby:标签顺序,默认是以名称排序;
order:升序还是降序。
修改完毕保存覆盖原文件即可。
然后还需要修改style.css对标签云进行其他关键设置代码如下,将下面代码粘贴到style.css最后即可
/** 标签云设置 **/ .widget_tag_cloud .tagcloud{ padding-top: 10px; height: auto; /** 这里也做了修改,让下部空间为自动,不然会有一大片空白色 **/ overflow: hidden; } .widget_tag_cloud a { float: left; display: block; padding: 0 1px; margin: 0 10px 10px 0; font-size: 1pt; /**上面文件改为PX后可自适应这里貌似不起作用了**/ background-color: #000000; /** 标签云背景色 **/ width: 84px;度 /** 标签云背景宽度 **/ background: #212121; color: #FFF; /** 标签云文字颜色 **/ text-align:center; /** 标签云文字居中 **/ }
3、评论头像的修改。 2016-12-20
经过一天时间的不懈努力最终也是没有成功搞定评论头像随机显示问题,最终只能单一显示自定义头像。
修改位置为主题下的functions.php文件,增加如下头像自定义代码。
/** 自定义头像图标 固定头像**/ add_filter( 'avatar_defaults', 'default_avatar' ); function default_avatar ($avatar_defaults) { $myavatar = get_bloginfo('template_directory') . '/images/avatar/1.jpg'; $avatar_defaults[$myavatar] = "默认头像"; return $avatar_defaults; }
4、后台编辑文章首行缩退2格问题,由于此功能对于我来说有点不适用所以取消
修改位置为css/editor-style.css文件搜索删除以下代码
} p { text-indent: 2em;
同时也删除了style.css的
} .single-content p { text-indent: 2em;  
5、增加表情调用文章数functions.php文件
//标签tag所包含的文章数量 function Tagno($text) { $text = preg_replace_callback('|<a (.+?)</a>|i', 'tagnoCallback', $text); return $text; } function tagnoCallback($matches) { $text=$matches[1]; preg_match('|title=(.+?)style|i',$text ,$a); preg_match("/[0-9]+/",$a[0],$b); return "<a ".$text ."<span>[".$b[0]."]</span></a>"; } add_filter('wp_tag_cloud', 'Tagno', 1);
6、评论添加@,functions.php文件
// 评论添加@,by 0912ITW.COM function ludou_comment_add_at( $commentdata ) { if( $commentdata['comment_parent'] > 0) { $commentdata['comment_content'] = '@<a href="#comment-' . $commentdata['comment_parent'] . '">'.get_comment_author( $commentdata['comment_parent'] ) . '</a> ' . $commentdata['comment_content']; } return $commentdata; } add_action( 'preprocess_comment' , 'ludou_comment_add_at', 20);
7、博客网速慢,反应慢,等待i0、i1、i2.wp.com响应,等待secure.gravatr.com响应。(貌似然并卵并没什么太大效果)
//解决等待i0、i1、i2.wp.com响应,等待secure.gravatr.com响应 function get_ssl_avatar($avatar) { $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=$2" class="avatar avatar-$2" height="$2" width="$2">',$avatar); return $avatar; } add_filter('get_avatar', 'get_ssl_avatar');
8、修改头部菜单,取消菜单,改为广告。
修改位置header.php,将源代码修改为以下
&lt;/script&gt; &lt;?php wp_head(); ?&gt; &lt;/head&gt; &lt;body &lt;?php body_class(); ?&gt;&gt; &lt;div id="page" class="page-site"&gt; &lt;div id="header-top"&gt; &lt;center&gt;本公司承接:榆林电脑家电销售维修,榆林网络维护,榆林监控安防,榆林弱电工程,榆林二手家电电脑回收等业务。 联系电话:15353163625&lt;/center&gt; &lt;/div&gt; &lt;?php get_template_part( 'inc/simple-menu' ); ?&gt;
9、增加底部常用调用显示数据。
修改位置为footer.php,在适当位置增加以下下几条调用代码。 &lt;center&gt; 建站天数:&lt;?php echo floor((time()-strtotime("2013-9-18"))/86400); ?&gt; 文章总数:&lt;?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts-&gt;publish;?&gt; 标签总数:&lt;?php echo $count_tags = wp_count_terms('post_tag'); ?&gt; 最后更新:&lt;?php $last = $wpdb-&gt;get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb-&gt;posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y-n-j', strtotime($last[0]-&gt;MAX_m));echo $last; ?&gt; &lt;/center&gt;
10、增加头部广告滚动条。
修改位置为header.php,与inc/bulletin.php
header部分轻微调整公告调用位置原代码如下
&lt;?php get_template_part( 'inc/logo' ); ?&gt; &lt;?php get_template_part( 'inc/nav-set' ); ?&gt; &lt;?php if (get_option('cx_bulletin') == 'true') { ?&gt; &lt;?php get_template_part( 'inc/bulletin' ); ?&gt;
修改后如下(将
&lt;?php get_template_part( 'inc/bulletin' ); ?&gt
;调至底部)
<pre>&lt;?php get_template_part( 'inc/logo' ); ?&gt; &lt;?php get_template_part( 'inc/nav-set' ); ?&gt; &lt;?php if (get_option('cx_bulletin') == 'true') { ?&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;nav id="site-nav" class="main-nav"&gt; &lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'header-menu', 'fallback_cb' =&gt; 'default_menu' ) ); ?&gt; &lt;ul&gt;&lt;li class="fill"&gt;&lt;/li&gt;&lt;/ul&gt; &lt;/nav&gt; &lt;!-- #site-nav --&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;?php get_template_part( 'inc/bulletin' ); ?&gt; &lt;/header&gt; &lt;!-- #header --&gt;</pre>
bulletin.php部分修改将原代码全部删除输入以下代码<style>
#announcement_box {background-color: rgba(240, 239, 215, 0.5);background-color: #E3DEC0 9;padding-left: 15px;margin: 10px auto!important;height: 30px;border: 1px dashed #C1C0AB;border-radius: 2px;} #announcement {background:url(http://7xpvhd.com1.z0.glb.clouddn.com/wp-content/themes/xiu2.1/images/notice_icon.png) left center no-repeat scroll; height:25px; line-height:25px; overflow: hidden;float:left;} #announcement a {color:#000;} #announcement a:hover {color:#94382B;} .announcement_remove {padding:1px 10px; float:right; font-size:14px;} .announcement_remove a {height:18px; width:18px; display:block; line-height:16px; margin:4px 0 3px 0; margin:10px 0 3px 0 9; text-align:center;} .announcement_remove a:hover {background-color:#cdc8a0; box-shadow:1px 1px 1px #66614c inset; -webkit-box-shadow:1px 1px 1px #666 inset; -moz-box-shadow:1px 1px 1px #666 inset; border-radius:3px;} #announcement_close {color:#666;} #announcement span {color:#666;} #announcement ul {list-style-type:none} &lt;/style&gt; &lt;div id="announcement_box" class="ption_a"&gt;//这里开始到下面 &lt;div id="announcement"&gt; &lt;ul style="margin-top: 0px;"&gt; &lt;i class="fa fa-volume-up" style="before"&gt;&lt;/i&gt; &lt;?php $args=array( 'notice' =&gt; wzgg, // 分类ID 'posts_per_page' =&gt; 5, // 显示篇数 ); query_posts($args); if(have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;li&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;span&gt; &lt;/li&gt; &lt;?php endwhile; endif; wp_reset_query(); ?&gt; //到这里--------------- &lt;li&gt;&lt;span class="mr10"&gt; 2015-4-25&lt;/span&gt;友情提示:可以使用键盘左右方向键来浏览上一篇和下一篇文章&lt;/li&gt; &lt;li&gt;&lt;span class="mr10"&gt; 2015-4-24&lt;/span&gt;老师上生物课,说到精子的结构和成分,老师说精子的主要成分是蛋白质,一女 生提问老师为什么不是甜的呢?全班爆笑,女生脸红跑出教室。&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="announcement_remove"&gt;&lt;a title="关闭" href="javascript:void(0)" rel="external nofollow" onClick="$('#announcement_box').slideUp('slow');"&gt;&lt;span id="announcement_close"&gt;×&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;script&gt; function AutoScroll(obj){ $(obj).find("ul:first").animate({ marginTop:"-25px" },500,function(){ $(this).css({marginTop:"0px"}).find("li:first").appendTo(this); }); } $(document).ready(function(){ setInterval('AutoScroll("#announcement")',4000) }); &lt;/script&gt;
下面这段代码完美调用任何分类文章列表,可以调用自定义ID的分类列表(如下图)
<pre>&lt;div id="announcement_box" class="ption_a"&gt;//这里开始到下面 &lt;div id="announcement"&gt; &lt;ul style="margin-top: 0px;"&gt; &lt;i class="fa fa-volume-up" style="before"&gt;&lt;/i&gt; &lt;?php $args=array( 'notice' =&gt; wzgg, // 分类ID (这里指定的分类列表费WP系统ID,此ID为主题自定义ID,定义ID名称问notice,ID为wzgg)(可以从前台直接观察,鼠标放到所要调用的文章分类处,如下图显示) 'posts_per_page' =&gt; 5, // 显示篇数 ); query_posts($args); if(have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;li&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;span&gt; &lt;/li&gt; &lt;?php endwhile; endif; wp_reset_query(); ?&gt; //到这里---------------
11、单独修改公告页面的头部广告与公告,方法如10,修改位置为header-bulletin.php
12、让网站所有链接都在新窗口打开。(由于网站内超链接数目较多,一个一个改起来他累所以,出此下策!)
修改位置为header.php,在最后面加上以下代码。
<base target="_blank" />
!!! 此页12条修改位置已完,后面修改位置将另起一贴.
- 我的微信
- 这是我的微信扫一扫
-
- 我的微信公众号
- 我的微信公众号扫一扫
-
2016年12月20日 下午10:52 沙发
@三五营销 常来转转