石木说
分类目录
最新留言
wordpress隐藏部分标签
WordPress的,通常是用tags和labels分别在侧栏显示标签云(cloud tags)和在文章中显示文章标记(Labels).由于分工不同,所以并不需要隐藏两个列表中的个别重复标签,但是如果当其中一个列表中的标签提供不一样的作用,就应该相对于另一个列表中的重复标签独立出来。
要不显示标签云中的部分标签并不是很困难因为 wp_tag_clud() 在codex都给出了相关的参数。例如,不显示ID为3和4的标签:
<?php wp_tag_cloud(‘smallest=10&largest=18&exclude=3,4′); ?>
通常来说,在文章中显示标签的功能,默认是没有添加任何参数来隐藏部分标签的:
<?php the_tags(”, ’, ‘, ”); ?>
但是, 我发现更改get_the_tags()可以实现这个功能。首先将以下代码放置在你当前使用主题文件的fuctions.php文件下:
/* Excluir tags en Posts */
function pk_the_tags( $before = ”, $sep = ’, ‘, $after = ”, $exclude = ” ) {
$tags = get_the_tags();
if ( empty( $tags ) )
return false;
$tag_list = $before;
foreach ( $tags as $tag ) {
if (!empty($exclude))
$pos = stripos( $exclude, $tag->name);
else
$pos = false;
if ($pos=== false)
$tag_links[] = ’<a href=”‘ . get_tag_link($tag->term_id) . ’”>’ . $tag->name . ’</a>’;
}
if (empty($tag_links))
return false;
$tag_links = join( $sep, $tag_links );
$tag_links = apply_filters( ’the_tags’, $tag_links );
$tag_list .= $tag_links;
$tag_list .= $after;
echo $tag_list;
}
如上面代码所显示的,每个Label列表的之前和之后都可以使用参数来分隔或隐藏你不想显示的标签。接着,你可以在主题文件的任何一部分调用这个函数,并通过名称来隐藏你不想显示标签。例如,隐藏标签称为“WordPress的”和“Blogger”的:
<?php if (get_the_tags()) pk_the_tags(”, ’, ‘, ”, ’Wordpress, Blogger’); ?>
转自:http://hi.baidu.com/wordpress321/blog/item/bda91a62f6636729ab184cbe.html
Next Supercontinent ‘Amasia’ Will Take North Pole Position: Scientific American
In 50 million to 200 million years’ time, all of Earth’s current continents will be pushed together into a single landmass around the North Pole. That is the conclusion of an effort,detailedin the February 9 issue ofNature,to model the slow movements of the continents over the next tens of millions of years. (Scientific Americanis part of Nature Publishing Group.)A supercontinent last formed 300 million years ago, when all the land masses grouped together on the equator as Pangaea, centered aboutwhere West Africa is now. After looking at the geology of mountain ranges around the world, geologists had assumed that the next supercontinent would form either in the same place as Pangaea, closing the Atlantic Ocean like an accordion,or on the other side of the world, in the middle of the current Pacific Ocean.
http://www.scientificamerican.com/article.cfm?id=next-supercontinent-amasia-wil
高价, 开放, 免费?
wordpress permalink
通常设置permalink(固定链接), 需在后台“/options-permalink.php”中设置即可,但是在“常规设置”里一旦设置了前缀(front),如“/archives/%post_id%”,作者归档页就变成了“/archives/author_base/%author%”,显然我们并不希望出现这样的URL,而是“/author_base/%author%”。
这时需要修改“/wp-include/rewrite.php”
有人提议在该文件末尾(php脚本结束前)添加以下代码:
function change_author_permalinks() {
global $wp_rewrite;
$wp_rewrite->author_base = ‘member’;
$wp_rewrite->author_structure = ‘/’ . $wp_rewrite->author_base. ‘/%author%’;
}
add_action(‘init’,'change_author_permalinks’);
其实只需修改文件中的代码即可,即找到以下代码:
function get_author_permastruct() {
if ( isset($this->author_structure) )
return $this->author_structure;if ( empty($this->permalink_structure) ) {
$this->author_structure = ”;
return false;
}$this->author_structure = $this->front . $this->author_base . ‘/%author%’;
return $this->author_structure;
}
将$this->front替换为 ’/’
变成
function get_author_permastruct() {
if ( isset($this->author_structure) )
return $this->author_structure;if ( empty($this->permalink_structure) ) {
$this->author_structure = ”;
return false;
}$this->author_structure = ‘/’ . $this->author_base . ‘/%author%’;
return $this->author_structure;
}
然后到后台“固定链接”更新一下即可







