分类目录归档:折腾

WordPress使用weavatar服务器替换Gravatar头像

WordPress留言评论头像老是加载不了,或者是偶尔断连,无奈只能另外寻找一个Gravatar服务器,代码如下。

if ( ! function_exists( 'get_cravatar_url' ) ) {
// 替换Gravatar头像为weavatar头像
function get_cravatar_url( $url ) {
$sources = array(
'www.gravatar.com',
'0.gravatar.com',
'1.gravatar.com',
'2.gravatar.com',
'secure.gravatar.com',
'cn.gravatar.com'
);
return str_replace( $sources, 'weavatar.com', $url );
}

add_filter( 'um_user_avatar_url_filter', 'get_cravatar_url', 1 );
add_filter( 'bp_gravatar_url', 'get_cravatar_url', 1 );
add_filter( 'get_avatar_url', 'get_cravatar_url', 1 );
}

if ( ! function_exists( 'set_defaults_for_cravatar' ) ) {
// 替换WordPress讨论设置中的默认头像
function set_defaults_for_cravatar( $avatar_defaults ) {
$avatar_defaults['gravatar_default'] = 'Cravatar 标志';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'set_defaults_for_cravatar', 1 );
}

WordPress首页文章页增加关键词和描述功能(SEO优化)

<?php
if (is_home()) {
$description = "自己的站点描述";
$keywords = "WordPress, 博客";
} elseif (is_single()) {
if ($post->post_excerpt) {
$description = $post->post_excerpt;
} else {
$description = substr(strip_tags($post->post_content), 0, 220);
}

$keywords = "";
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag) {
$keywords .= $tag->name . ", ";
}
}
?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<meta name="description" content="<?php echo $description; ?>" />

使用方法:

将这段代码添加到主题的header.php页面,<title>***</title>下方保存即可。

Twenty Twelve: content.php 修改摘要版

<?php
/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */
?>


<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<div class="featured-post">
<?php _e( 'Featured post', 'twentytwelve' ); ?>
</div>
<?php endif; ?>
<header class="entry-header">
<?php
if ( ! post_password_required() && ! is_attachment() ) :
the_post_thumbnail();
endif;
?>


<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h1>
<?php endif; // is_single() ?>
<?php if ( comments_open() ) : ?>
<div class="comments-link">
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
</div><!-- .comments-link -->
<?php endif; // comments_open() ?>
</header><!-- .entry-header -->


<?php if ( is_search() ) : // Only display excerpts for search. ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">


    <?php if ( is_single() && 'post' == get_post_type() ) : ?>
    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
    <?php else : ?>
    <?php echo wp_trim_words(get_the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ) ,350," ..."); ?>


    <?php if(strlen(wp_strip_all_tags(get_the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ))) >=350 ) :?>
    <a href="<?php the_permalink(); ?>" rel="bookmark">阅读更多</a>
    <?php endif; ?>


    <?php endif; ?>


    <?php
    wp_link_pages(
        array(
            'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ),
            'after'  => '</div>',
        )
    );
    ?>
</div><!-- .entry-content -->
<?php endif; ?>


<footer class="entry-meta">
<?php twentytwelve_entry_meta(); ?>
<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
<?php
// If a user has filled out their description and this is a multi-author blog, show a bio on their entries.
if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) :
?>
<div class="author-info">
<div class="author-avatar">
<?php
/** This filter is documented in author.php */
$author_bio_avatar_size = apply_filters( 'twentytwelve_author_bio_avatar_size', 68 );
echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size );
?>
</div><!-- .author-avatar -->
<div class="author-description">
<h2>
<?php
/* translators: %s: Author display name. */
printf( __( 'About %s', 'twentytwelve' ), get_the_author() );
?>
</h2>
<p><?php the_author_meta( 'description' ); ?></p>
<div class="author-link">
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
<?php
/* translators: %s: Author display name. */
printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve' ), get_the_author() );
?>
</a>
</div><!-- .author-link -->
</div><!-- .author-description -->
</div><!-- .author-info -->
<?php endif; ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->

网站迎接备案,暂停一会儿!

折腾的人,终归又要折腾回去!

准备从cloudcone国外服务器,搬家到国内的腾讯云轻量服务器上。

腾讯云之前一次性购买了5年的(活动优惠价),速度挺可以的。

为什么要搬家,还是因为国外的服务器速度慢了,如果网站内容是纯文字,少图片,cloudcone其实还是可以满足的。毕竟活动价才只要24.9$.。2H3G50G的硬盘

休息几个工作日再回来折腾吧。


其实老早想退cloudcone的服务器的,奈何等了几天,网站工单一直没有回复,钱退不到支付宝,就又购买用上了,白花24.9$,以后放着也不知道能用来做什么。

还有一个cloudcone的小细节,就是购买的服务器很多会被墙,墙了只要可以通过销毁–退钱到平台–等几个小时–再次购买的方法来刷ip,其中也许就有没有被墙的ip噢。

从新拾起WordPress博客建站

接触博客建站好几个年头了,也许是十几个年头,从一开始的blog系统,PJBlog到emlog再到zblog,WordPress …..!

小年轻冒着好奇心对“个人网站”产生了兴趣,找免费域名+免费的虚拟空间,放一个单页+一个免费域名就能做一个简单的个人主页。

独自学习了怎么搭建网站,独立域名+服务器环境搭建,网站如何变现,如何引流,如何优化,一步步不知道折腾了好久,买域名建站再删站,断断续续不低于十个年头。

前五六年开始还想学习如何用PHP制作网站,学习PHP+WEB,后面可能真的是时间不够还是“老了”就放弃了,课程都买了不下八千快钱QAQ!(不知道以后会不会继续学习!)

我上班的工作内容是电商推广运营,全年休息比较少,虽然身体上不觉得累,但是脑壳儿真的一年不如一年,一休息下来就想躺着放松脑袋。要我坐在电脑面前撸代码扣hello world!实属有点难受。而自己又是一个不怎么“坚持”的人。

WordPress是我建站系统用的最多的程序,最初用多了感觉会有些臃肿,其实还好,准备是换typecho博客系统的,犹豫了,因为WordPress提供了强大的后台插件系统和优秀主题。对于小白的自己来说,完美适配,不用自己各种查找。

这次匆匆而来,希望网站能一直坚持下去,留点东西,当个备忘录也挺好的。

antbk.com是我网站的域名,域名的由来是这样的,想做个人博客,记录一些生活琐碎,笔记类。就联想到了“旧帐本”这个词。苦于没有灵感域名该如何注册,就跑到了QQ浏览器的AI助手

我就问AI,我想创建一个网站,网站博客标题想起一个关于旧帐本的博客,请帮推荐下注册域名,要求是.com域名,并且长度为5~8个字母

AI给了我好几个关于旧+book的域名,其中就有一条Antiquebook,古董+博客的意思,我又感觉太长请帮我缩短成简写5-7位字母。

AI最终给出了Antbk.com这个域名!所以此时此刻,antbk.com网站域名就被我注册了,并且诞生了这个WordPress网站,我的旧帐本

他来了,希望他能陪我走的更远一点,如果真的有一天没了,那么我可能真的就已经老了,生活总归要有点乐趣,或许这就是我的乐趣之一,再没有找到其他乐趣之前,他,这个博客会陪着我吧。