不使用插件怎么自动在wordpress博客文章末尾添加转载版权声明?

作者: 站长 上传时间: 浏览: N/A 下载: N/A 格式: N/A 评分: N/A

wordpress博客文章自动在末尾添加转载版权声明的方法:

1,single.PHP的合适位置添加以下代码(效果见本网站)

<!– 转载声明开始 –>
原文:<a rel=”bookmark” title=”<?php the_title(); ?>” href=”<?php the_permalink(); ?>”>《<?php the_title(); ?>》</a><br />
转载自网站:<a href=”<?php echo get_settings(‘home’); ?>”><?php bloginfo(‘name’); ?></a>
</a>
<!– 转载声明结束 –>

2,还有一种可以就是别人复制的时候就自动把版权复制到粘贴板:

<!– 复制加版权开始 –>

<script type=”text/javascript”>

document.body.oncopy=function(){

event.returnValue=false;

var t=document.selection.createRange().text;

var s=”本文来源于<?php bloginfo(’name’); ?> <?php echo get_settings(’home’); ?> , 原文地址: <?php the_permalink() ?> “;

clipboardData.setData(’Text’,’rn’+t+’rn’+s+’rn’);

}

</script>

<!– 复制加版权结束 –>

标签:

2 thoughts on “不使用插件怎么自动在wordpress博客文章末尾添加转载版权声明?

  1. 老牛,我想问一下wordpress侧边的近期评论格式是:用户名+评论的文章,我在百度上面找了方法来修改( WordPress文件夹 > wp-includes > default-widgets.php),但是修改了代码以后出现了网站空白,我想是代码上有错误:
    if ( $comments ) {
    // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
    $post_ids = array_unique( wp_list_pluck( $comments, ‘comment_post_ID’ ) );
    _prime_post_caches( $post_ids, strpos( get_option( ‘permalink_structure’ ), ‘%category%’ ), false );

    foreach ( (array) $comments as $comment) {
    $output .= ”;
    /* translators: comments widget: 1: comment author, 2: post link */
    $output .= sprintf( _x( ‘%1$s on %2$s’, ‘widgets’ ),
    ” . get_comment_author_link() . ”,
    comment_ID ) ) . ‘”>’ . get_the_title( $comment->comment_post_ID ) . ‘
    );
    $output .= ”;
    }
    }

    我是把上面的代码修改成:
    if ( $comments ) {
    2
    foreach ( (array) $comments as $comment) {
    3
    $output .= ” . ‘comment_ID)) . ‘” title=”‘.get_the_title($comment->comment_post_ID).’,’.get_comment_date(Y-m-j).'”>’ . mb_strimwidth(strip_tags($comment->comment_content), 0, 45,”…”) . ‘‘ . ”;
    4
    }
    5
    }

    然后就出现网站空白了,请问下要怎么修改

Leave a Comment