post 的[more] 标签 , 用 “ read more” 的icon 代替。

[复制链接]
查看: 909   回复: 5
发表于 2013-11-6 21:42:55 | 显示全部楼层 |阅读模式
本帖最后由 hardrock 于 2013-11-7 23:52 编辑

WordPress ,是英文网站,   post 截取帖子字数 [more] 标签 ,
post 的[more] 标签 , 用  “read more” 的icon 代替。
,代码应该怎么实现 ? 或用什么插件实现?
1, 有个中文插件“日志自动截断”  可以代替[more] 标签 ,我就是不知道类似的英文插件叫什么?
Limit Posts Automatically (2007年的,有无类似的比较新的)
主要是英语不好,不知用什么关键字搜索

2, 还有关于“面包屑导航”插件,类似的英文插件叫什么?





post 的[more] 标签 , 用 “ read more” 的icon 代替。


发表于 2013-11-7 09:44:31 | 显示全部楼层
1、在the_content( ) 里修改:
  1. <?php the_content('<img  src="http://XXX.com/read-more.png" alt="Arrow"  title="Read more" />'); ?>
复制代码
2、在function.php文件里添加这段代码:
  1. function fairy_breadcrumbs() {
  2.     $delimiter = '&raquo;';
  3.       $home = '首页'; // text for the 'Home' link
  4.       $before = '<span class="current">'; // tag before the current crumb
  5.       $after = '</span>'; // tag after the current crumb
  6.       if ( !is_home() && !is_front_page() || is_paged() ) {
  7.         echo '<div id="crumbs">';
  8.         global $post;
  9.         $homeLink = get_bloginfo('url');
  10.         echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
  11.      if ( is_category() ) {
  12.           global $wp_query;
  13.           $cat_obj = $wp_query->get_queried_object();
  14.          $thisCat = $cat_obj->term_id;
  15.           $thisCat = get_category($thisCat);
  16.           $parentCat = get_category($thisCat->parent);
  17.           if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
  18.               echo $before . ' "' . single_cat_title('', false) . '" 目录下的文章' . $after;
  19.     } else if ( is_single() && !is_attachment() ) {
  20.       if ( get_post_type() != 'post' ) {
  21.         $post_type = get_post_type_object(get_post_type());
  22.         $slug = $post_type->rewrite;
  23.         echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $delimiter . ' ';
  24.         echo $before . get_the_title() . $after;
  25.       } else {
  26.         $cat = get_the_category(); $cat = $cat[0];
  27.         echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  28.         echo $before . get_the_title() . $after;
  29.       }
  30.     } else if ( !is_single() && !is_page() && get_post_type() != 'post' ) {
  31.           $post_type = get_post_type_object(get_post_type());
  32.           echo $before . $post_type->labels->singular_name . $after;
  33.     }
  34.     if ( get_query_var('paged') ) {
  35.           if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  36.           echo __('Page') . ' ' . get_query_var('paged');
  37.           if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  38.     }
  39.     echo '</div>';
  40. }
复制代码
然后在你要用面包屑导航的地方添加(比如正文标题下面)
  1. <?php if (function_exists( 'fairy_breadcrumbs')) fairy_breadcrumbs(); ?>
复制代码

点评

好人啊  发表于 2013-11-7 21:54

评分

参与人数 4T币 +10 收起 理由
hardrock + 1 感謝支持!
gger + 3 認眞參與
luguokankan + 3
若鱼 + 3

查看全部评分

回复 支持 反对

使用道具 举报

发表于 2013-11-7 17:46:03 | 显示全部楼层
yyqslly 发表于 2013-11-7 09:44 post 的[more] 标签 , 用 “ read more” 的icon 代替。
1、在the_content( ) 里修改:2、在function.php文件里添加这段代码:然后在你要用面包屑导航的地方添加( ...

恩,breadcrumb的实现看起来很复杂, 而且不支持microdata https://support.google.com/webmasters/answer/185417?hl=en

我建议直接使用插件, 如wordpress seo

不过,谢谢您的分享 post 的[more] 标签 , 用 “ read more” 的icon 代替。

评分

参与人数 1T币 +1 收起 理由
hardrock + 1 wordpress seo中有功能代替[more] 标签??.

查看全部评分

回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-11-7 22:54:55 | 显示全部楼层
本帖最后由 hardrock 于 2013-11-7 23:45 编辑

1, 有个中文插件“日志自动截断”  可以代替[more] 标签 ,我就是不知道类似的英文插件叫什么?
Limit Posts Automatically (2007年的,有无类似的比较新的), Save Excerpt Automatically
2, 还有关于“面包屑导航”插件,类似的英文插件叫什么?



回复 支持 反对

使用道具 举报

发表于 2013-11-8 09:32:26 | 显示全部楼层
能不用插件就不用插件,毕竟有些功能改代码就可以实现了。post 的[more] 标签 , 用 “ read more” 的icon 代替。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-11-12 22:54:52 | 显示全部楼层
本帖最后由 hardrock 于 2013-11-12 22:56 编辑

1, Better Read More
2. 这个反而可以用插件wordpress seo by yoast来做,本身有的。   Breadcrumb NavXT
谢谢猪农

post 的[more] 标签 , 用 “ read more” 的icon 代替。



补充内容 (2014-1-12 22:07):
Better Read More 不好

补充内容 (2014-1-12 22:28):
the_content()位于wp-includes/post-template.php
<?php the_content( $more_link_text, $strip_teaser, $more_file ); ?>



补充内容 (2014-1-12 22:30):
<?php the_content('...continue<img src="/images/leaf.gif"
alt="read more" title="Read more" />'); ?>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则