春节闲赋在家无事,把博客又重新布置了一遍。分别把四个分类目录”札记“,”兴趣“,“琐忆”,“电脑“,名字改为:”生活漫步“(shenghuo-manbu), “兴趣发现”(xingqu-faxian),“ 时光絮语”(shiguang-xuyu),“ 技术笔记”(/jishu-biji),重设别名。又新增加“碎语札记”(suiyu-zhaji)版块。
没流量就不在意流量,彻底的改一遍,重置不是整改开天窗,是扒房子重建。索性把过去复杂各种伪静态,改成简短有未来感的”/%postname%/“结构。并优化关键词和描述。
<meta name="keywords" content="载润札记, 个人博客, 生活感悟, 旅行与摄影, 技术分享, 风俗文化, 生活点滴, 碎语札记, 兴趣探索" /> <meta name="description" content="载润札记,我的个人博客,日常碎语札记和你一同感受生活感悟,分享旅行与摄影的乐趣,探索技术分享的奥秘,领略风俗文化的风情,记录生活点滴和兴趣探索。期待在这里与你相遇!" />
碎语札记板块关键词和描述
<?php // 在wp_head中添加关键词和描述 add_action('wp_head', function() { // 添加关键词 $keywords = '碎语札记, 生活, 记录, 日常感悟, 灵感, 碎片化, 每日灵感碎片'; echo '<meta name="keywords" content="' . esc_attr($keywords) . '">'; // 添加描述 $description = '日常碎语札记,记录生活中的点滴感悟,分享摄影作品和那些转瞬即逝的灵感。不拘泥于形式,不追求完整,只言片语,碎片化生活记录。'; echo '<meta name="description" content="' . esc_attr($description) . '">'; }); ?>
碎语札记模板笔札,记录这里为了自己日后鼓秋方便查找。
阅读量插件调用代码
<span class="page-views" style="margin-left: 10px; font-size: 14px; color: #666;"> <?php if ( function_exists( 'pvc_get_post_views' ) ) { $page_views = pvc_get_post_views( get_the_ID() ); echo '浏览次数: ' . $page_views; } ?> </span>
碎语札记模板,点赞插件调用代码
<?php if (function_exists('wp_ulike')) { echo do_shortcode(''); } ?>
添加碎语札记RSS订阅
<!-- RSS 订阅链接 --> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> 碎语订阅" href="<?php echo esc_url(home_url('/feed/suiyu')); ?>" /> </a> </div>
网站Robots.txt文件
User-Agent: * # 允许访问特定文件 Allow: /wp-content/uploads/ Allow: /suiyu/feed/ # 禁止访问管理后台和插件目录 Disallow: /wp-admin/ Allow: /wp-admin/admin-ajax.php # 例外:允许访问 ajax 文件 Disallow: /wp-content/plugins/ # 禁止访问其他敏感文件 Disallow: /readme.html Disallow: /refer/ # Sitemap 地址 Sitemap: https://www.zairun.com/sitemap.xml Sitemap: https://www.zairun.com/sitemap.html
主题自定义标签美化代码
/* 标题容器 */ .title-container { display: flex; /* 使用 Flexbox */ align-items: center; /* 图标与标题容器垂直方向居中 */ justify-content: center; /* 水平方向居中 */ gap: 15px; /* 图标和文字之间的间距 */ } /* 标题文字容器 */ .title-text { text-align: center; /* 文字居中 */ } /* 主标题样式 */ #site-title { font-size: 1.4em; /* 主标题字体大小 */ margin: 0; line-height: 1.2; /* 行高 */ } /* 主标题链接样式 */ #site-title a { text-decoration: none; /* 去掉下划线 */ color: #333; /* 主标题颜色 */ } /* 副标题样式 */ #site-description { font-size: 0.6em; /* 副标题字体大小 */ color: #666; /* 副标题颜色 */ margin: 0; margin-top: 5px; /* 增加主标题和副标题的间距 */ line-height: 1.4; } /* 图标样式 */ .site-icon { height: 1.8em; /* 设置图标高度与主标题字体大小一致 */ width: auto; /* 按比例缩放宽度 */ display: inline-block; } /* 小工具标题字体 */ .widget-title { font-family: 'Arial', sans-serif; /* 替换为你需要的字体 */ font-size: 14px; /* 标题字体大小 */ font-weight: bold; /* 标题字体加粗 */ color: #333; /* 标题颜色 */ } .tagcloud a { background: linear-gradient(45deg, #FFFFFF, #FFFFFF); color: #fff; font-weight: bold; padding: 5px 10px; border-radius: 30px; transition: all 0.3s ease; font-family: "Georgia", serif; /* 使用文艺气息的字体 */ color: #333; text-decoration: none; background-color: #FFFFFF; border: 1px solid #ddd; border-radius: 20px; transition: all 0.3s ease; } .tagcloud a:hover { transform: scale(1.1); box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); }
文章照片灯箱特效,添加模板functions.php文件代码
// 添加灯箱功能到文章图片 function add_image_lightbox() { if (is_single() && 'post' == get_post_type()) { // 仅文章页生效 ?> <style> /* 灯箱容器 */ .lightbox-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); display: none; z-index: 9999; cursor: zoom-out; } /* 放大后的图片 */ .lightbox-image { position: absolute; max-width: 90%; max-height: 90%; top: 50%; left: 50%; transform: translate(-50%, -50%); transition: transform 0.3s ease; cursor: grab; } /* 图片加载指示器 */ .lightbox-loading { width: 50px; height: 50px; border: 3px solid #fff; border-radius: 50%; border-top-color: transparent; animation: spin 1s linear infinite; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } @keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } } /* 文章图片点击样式 */ .entry-content img { cursor: zoom-in; transition: transform 0.2s; } .entry-content img:hover { transform: scale(1.02); } </style> <div class="lightbox-overlay"> <div class="lightbox-loading"></div> <img class="lightbox-image" src="" alt="Enlarged view"> </div> <script> (function() { // 初始化灯箱 const overlay = document.querySelector('.lightbox-overlay'); const lightboxImg = overlay.querySelector('img'); let isDragging = false; let startX, startY, translateX = 0, translateY = 0; // 点击图片触发 document.querySelectorAll('.entry-content img').forEach(img => { if (!img.closest('a')) { // 排除已有链接的图片 img.style.cursor = 'zoom-in'; img.addEventListener('click', function(e) { e.preventDefault(); showLightbox(this.src, this.alt); }); } }); // 显示灯箱 function showLightbox(src, alt) { overlay.style.display = 'block'; lightboxImg.style.transform = 'translate(-50%, -50%) scale(0.8)'; lightboxImg.style.opacity = '0'; // 预加载高清图(如果有data-large属性) const largeSrc = src.replace(/-\d+x\d+\./, '.'); // 自动去除WordPress缩略图尺寸 const imgLoader = new Image(); imgLoader.onload = () => { lightboxImg.src = largeSrc; lightboxImg.alt = alt; lightboxImg.style.transform = 'translate(-50%, -50%) scale(1)'; lightboxImg.style.opacity = '1'; overlay.querySelector('.lightbox-loading').style.display = 'none'; }; imgLoader.src = largeSrc; } // 关闭灯箱 overlay.addEventListener('click', (e) => { if (e.target === overlay || e.target === lightboxImg) { overlay.style.display = 'none'; lightboxImg.src = ''; translateX = translateY = 0; // 重置位置 } }); // 移动端手势支持 let touchStartX, touchStartY; lightboxImg.addEventListener('touchstart', (e) => { touchStartX = e.touches[0].clientX; touchStartY = e.touches[0].clientY; }, { passive: true }); lightboxImg.addEventListener('touchmove', (e) => { e.preventDefault(); // 阻止页面滚动 const touch = e.touches[0]; const deltaX = touch.clientX - touchStartX; const deltaY = touch.clientY - touchStartY; lightboxImg.style.transform = `translate(calc(-50% + ${deltaX}px), calc(-50% + ${deltaY}px))`; }, { passive: false }); lightboxImg.addEventListener('touchend', () => { touchStartX = touchStartY = null; lightboxImg.style.transform = 'translate(-50%, -50%)'; }); // 键盘控制 document.addEventListener('keydown', (e) => { if (overlay.style.display === 'block') { if (e.key === 'Escape') overlay.style.display = 'none'; if (e.key === 'ArrowLeft') navigate(-1); if (e.key === 'ArrowRight') navigate(1); } }); })(); </script> <?php } } add_action('wp_footer', 'add_image_lightbox');