使用教程:
需要 修改主题里面的文件 functions.php
如果害怕更新丢失,可以使用子主题或者在functions.php 里面引入 func.php。
子主题 onenav-child
下面是插入到 func.php 里面的代码:
引入 func.php
代码展示
.topgj_r {margin-right: 15px;display: flex;align-items: center;height: 100%;}.topgj_r .menu-item {position: relative;height: 100%;display: flex;align-items: center;}.topgj_r .menu-item a {padding: 8px;color: #282a2d;display: flex;align-items: center;font-size: 13px;transition: all 0.3s ease;}.io-black-mode .topgj_r .menu-item a {color: #c6c9cf;}.topgj_r .sub-menu-z {position: absolute;top: 100%;right: 50%;transform: translateX(50%);min-width: 90px;background: #fff;border-radius: 8px;box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);opacity: 0;visibility: hidden;transform-origin: top center;transition: all 0.25s cubic-bezier(0.3, 0, 0.3, 1);z-index: 1000;padding: 8px 0;margin: 0;list-style-type: none;}.io-black-mode .topgj_r .sub-menu-z {background: #2c2e2f;}.topgj_r .menu-item:hover .sub-menu-z {opacity: 1;visibility: visible;transform: translateX(50%) translateY(0);}.sub-menu-z .menu-item-z {list-style: none;margin: 0;padding: 0;white-space: nowrap;text-align: center;}.sub-menu-z .menu-item-z a {padding: 8px 16px;color: #666 !important;font-size: 13px;display: flex;align-items: center;justify-content: center;transition: all 0.2s ease;text-decoration: none;width: 100%;}.sub-menu-z .menu-item-z span {display: inline-block;text-align: center;width: 100%;}.io-black-mode .sub-menu-z .menu-item-z a {color: #c6c9cf !important;}.sub-menu-z .menu-item-z a:hover {background: rgba(0, 0, 0, 0.04);color: #333 !important;}.io-black-mode .sub-menu-z .menu-item-z a:hover {background: rgba(255, 255, 255, 0.08);color: #fff !important;}.navbar-menu .menu-item i {margin-right: 5px;}@media (max-width: 992px) {.topgj_r {display: none;}}
// 使用 WordPress 钩子在 flex-fill 后面添加自定义内容 add_action('wp_head', 'add_custom_content_after_flex_fill'); function add_custom_content_after_flex_fill() { // 检查当前页面是否加载了头部模板 ob_start(); // 开启输出缓冲 ?>
document.addEventListener("DOMContentLoaded", function() {
// 查找 header-nav blur-bg 元素
var headerNav = document.querySelector('.header-nav.blur-bg');
if (headerNav) {
// 只在 headerNav 内部查找 flex-fill
var flexFillElement = headerNav.querySelector('.flex-fill');
if (flexFillElement) {
// 创建自定义内容
var customContent = document.createElement('div');
customContent.innerHTML = `
`; // 将自定义内容插入到 flex-fill 后面 flexFillElement.insertAdjacentElement('afterend', customContent); } } }); <?php echo ob_get_clean(); // 输出缓冲内容 }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。