存档

文章标签 ‘建站’

wordpress代码高亮插件优化

2009年4月13日

昨天发布代码的时候就发现显示总是会出错,还会使页面错乱,下了几种插件,在这个主题下都无法使用,出现错误,也不想去看代码了,最后选择了wp-syntax[1].0.9.3,下载地址:

    http://downloads.wordpress.org/plugin/wp-syntax.0.9.3.zip

使用方法:

所要显示的代码

支持代码种类:
abap, actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp, csharp, css, d, delphi, diff, div, dos, dot, eiffel, fortran, freebasic, genero, gml, groovy, haskell, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, m68k, matlab, mirc, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, per, perl, php-brief, php, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80

但随即又出现了问题,不支持代码自动换行,最后终于找到了解决办法,修改所用主题的CSS文件,添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.wp_syntax {
  color: #100;
  background-color: #f9f9f9;
  border: 1px solid silver;
  margin: 0 0 1.5em 0;
  overflow: auto;
}
 
/* IE FIX */
.wp_syntax {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: expression(this.scrollWidth > this.offsetWidth ? 15 : 0);
}
 
.wp_syntax table {
  table-layout:fixed;
  overflow:hidden;
  text-overflow:ellipsis;
  WORD-BREAK: break-all;
  WORD-WRAP: break-word;
  border-collapse: collapse;
}
 
.wp_syntax div, .wp_syntax td {
  vertical-align: top;
  padding: 2px 4px;
}
 
.wp_syntax .line_numbers {
  text-align: right;
  background-color: #def;
  width:30px;
  color: gray;
  overflow: visible;
  font-family: 'Lucida Grande',
  'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif;
}
 
/* potential overrides for other styles */
.wp_syntax pre {
  margin: 0;
  width: fixed;
  float: none;
  clear: none;
  WORD-BREAK: break-all;
  WORD-WRAP: break-word;
  overflow: visible;
  font-size:8pt;
  font-family: Courier New;
}
作者: feeloc 分类: 建站 标签: ,

wordpress显示文章摘要的方法

2009年4月12日

wordpress的很多主题,在主页中都无法显示文章摘要,虽然有很多插件可以完成这一功能,但没有下面这个方法使用方便。其实问题就是出现在

1
<?php the_content(); ?>

这行代码中。根据自己所用的主题,找到home.php,如果没有就找到index.php,找到

1
<?php the_content(); ?>

这句代码,将其修改为:

1
2
3
4
5
6
7
8
9
10
11
12
<?php if(is_category() || is_archive() || is_home() )
{
    the_excerpt();
}
else
{
    the_content('Read the rest of this entry &raquo;');
} ?>
<div class="details">
<div class="inside">
<?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> so far | <a href="<?php the_permalink() ?>">Read On &raquo;</a></div>
</div>

如果自己的主题没有category或者archive页面,可根据实际情况修改。
这样使各个页面都以文章摘要的形式输出,不仅使自己页面看上去整洁,也有利于搜索引擎人优化。

作者: feeloc 分类: 建站 标签: ,