分类: 主题美化

  • WordPress官方2022主题Twenty Twenty-Two不使用插件如何添加GA或百度统计等网站追踪代码

    WordPress官方2022主题Twenty Twenty-Two不使用插件如何添加GA或百度统计等网站追踪代码

    WordPress在5.9版本之后启用的官方Twenty Twenty-Two主题和之前的主题有很大的区别,引入了theme.json的配置文件,其他的大部分php文件也都换成了html文件,让人一下子有些不知所措。

    如果你也只喜欢用原生的主题,切换到Twenty Twenty-Two主题的时候,自然要把之前在标签<head>和<foot>当中的一些JS代码引入到新的主题当中。那么你会发现新版主题的所有文件当中你已经找不到项目的标签了:

    <head>......</head>
    
    <foot>.....</foot>

    然而大部分网站追踪网站,不管是谷歌分析还是百度统计都要求你把代码放到</head>标签之前,但是现在找不到了!!!ITGeeker技术奇客搜索了一番也没找到相关说明,又不想使用插件来添加,那么想到了通过Wordpress的函数wp_head“和” “wp_footer”来实现此功能。

    只需两步:

    1. 创建Twenty Twenty-Two的子主题(twentytwentytwo-child)

    安装惯例,创建Wordpress的继承子主题目录twentytwentytwo-child放到wp-content目录,可以包含:style.css,functions.php和theme.json文件,除了style.css需要有以下内容,其他也都可以是空白:

    @charset "UTF-8";
    
    /*
    Theme Name: Twenty Twenty-Two (ITGeeker.net)
    Author: ITGeeker
    Author URI: https://www.itgeeker.net/
    Description: Twenty Twenty-Two child by itgeeker
    Version: 1.1
    Template: twentytwentytwo
    */
    @import url("../twentytwentytwo/style.css");
    /* !important 命令 这样下面的css代码就会覆盖父级css*/

    2. 使用wp_head和wp_footer添加JS或其它内容

    在functions.php文件可以加入GA跟踪代码到Head部分,alert部分可以作为测试用。

    /* Insert Headers */  
    function insert_itgeeker_head() {
        ?>
            <!-- <script>
                alert('Page is loading by itgeeker.net ...');
            </script> -->
            <!-- Global site tag (gtag.js) - Google Analytics -->
            <script async src="https://www.googletagmanager.com/gtag/js?id=G-你的GA衡量 ID"></script>
            <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
    
            gtag('config', 'G-你的GA衡量 ID');
            </script>
        <?php
    }
    add_action('wp_head', 'insert_itgeeker_head');
    /* Insert Footers*/  
    function insert_itgeeker_footer() {
        echo '<p style="text-align: center; font-size: x-small;">网站由<a href="https://www.itgeeker.net">ITGeeker技术奇客</a>开发并管理;
        隶属于<a href="https://www.geekercloud.com">GeekerCloud奇客罗方智能科技</a></p>
        <p style="text-align: center; font-size: x-small;">Site designed and developed by <a href="https://www.itgeeker.net">ITGeeker</a>
        which is a sub-website of <a href="https://www.geekercloud.com">GeekerCloud</a></p>
    ';
    }
    add_action( 'wp_footer', 'insert_itgeeker_footer', 100 );

    这里在页脚添加是一段文字,如果要添加JS的脚本的话,要和header部分一样用?><?php来包括已下,例如添加鼠标特效JS:

    function insert_itgeeker_footer() {
        ?>
        <!-- 鼠标特效 -->
        <script type="text/javascript">
        var a_idx = 0;
        jQuery(document).ready(function($) {
            $("body").click(function(e) {
                var a = new Array("技术奇客", "奇客大师", "自由奇客", "奇客顾问", "奇客罗方", "ITGeeker", "FreeGeeker", "GeekerCloud", "GeekerMaster", "GeekerConsulting");
                var $i = $("<span />").text(a[a_idx]);
                a_idx = (a_idx + 1) % a.length;
                var x = e.pageX,
                y = e.pageY;
                $i.css({
                    "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
                    "top": y - 20,
                    "left": x,
                    "position": "absolute",
                    "font-weight": "bold",
                    "color": "#ff6651"
                });
                $("body").append($i);
                $i.animate({
                    "top": y - 180,
                    "opacity": 0
                },
                1500,
                function() {
                    $i.remove();
                });
            });
        });
        </script>
        <?php
    
        echo '<p style="text-align: center; font-size: x-small;">网站由<a href="https://www.itgeeker.net">ITGeeker技术奇客</a>开发并管理;
        隶属于<a href="https://www.geekercloud.com">GeekerCloud奇客罗方智能科技</a></p>
        <p style="text-align: center; font-size: x-small;">Site designed and developed by <a href="https://www.itgeeker.net">ITGeeker</a>
        which is a sub-website of <a href="https://www.geekercloud.com">GeekerCloud</a></p>';
    }
    add_action( 'wp_footer', 'insert_itgeeker_footer', 100 );
  • 微软发布的Windows 8风景主题下载

    微软的Windows 8主题都是由摄影师们和艺术家们提供的精美照片组成的。
    win8theme1

    这次Kyle Waters为人们带来的是一组摄制于阿拉斯加的风景照。Ian Rushton为人们带来了全新两组的新西兰风景主题,另外还有一个是讲述瑞典春天的主题。

    win8theme2

    Alaskan Landscapes下载地址:http://windows.microsoft.com/en-us/windows/alaskan-landscapes-download-theme

    win8theme4

    新西兰风景主题一Queenstown下载地址:http://windows.microsoft.com/en-us/windows/new-zealand-queenstown-download-theme

    win8theme3

    新西兰风景主题二One Tree Hill下载地址:http://windows.microsoft.com/en-us/windows/one-tree-hill-download-theme

    win8theme5

    瑞典春天主题下载地址:http://windows.microsoft.com/en-us/windows/swedish-spring-download-theme

    除了自然风景主题之外,这次发布的主题还有一个则是来自艺术家Karyn Servin的“美味设计(Delectable Designs)”。这组主题主要展示了各种各样的纸杯蛋糕以及各种各样的甜点。

    win8theme6

    Delectable Designs下载地址:http://windows.microsoft.com/en-us/windows/delectable-designs-download-theme

    微软还发布了一系列的桌面壁纸,它们可支持老版Windows以及最新的Windows 7和8系统。

    桌面背景下载地址:http://windows.microsoft.com/en-US/windows/wallpaper

  • Windows 7官方主题:《鬼镇》

    1879年,美国加利福尼亚州的博迪(Bodie)如闪电一般诞生,因丰富的矿藏而蓬勃发展,然而在淘金热褪去后,居民渐渐地离去,再加上1932年的那 一场大火,博迪成为了一个废弃城镇。那些加油站,电桿,旧消防局,校舍,空房子,博物馆文件记载著这个地方的消逝,如同受到诅咒一样,在美国的历史上,渐渐被人彻底遗忘。今天,微软发布了一则Windows 7官方主题《鬼镇》,跨越百年,重拾博迪印象。

    [singlepic id=1 w=680 h=480 mode=web20 float=center]

    [nggallery id=1]

    壁纸图赏:

    [imagebrowser id=1]

    官方下载: 

    http://download.microsoft.com/download/7/2/8/728E3928-EE04-4A76-A09F-2A00EA444432/GhostTownTracyHymas.themepack

  • Windows 7官方主题 《兽之恋》

    无论是亲子之间的舐犊情深,还是伴侣间的恩爱患难,动物们之间的感情有时候比人类更加纯粹。微软今天发布了一款描写动物感情的Windows 7主题《兽之恋》,爱情是美好的,动物之间的爱恋亦是如此,在这款主题中,小鸟的依偎、天鹅的交颈、马儿的亲吻……都是那么地甜蜜温馨。

    壁纸图赏:

    官方下载: http://download.microsoft.com/download/7/F/2/7F2F0382-FAA4-4CBE-B567-AB49ED8A3F24/AnimalAffection.themepack

  • 微软官方Win7主题《趣味水果》

    虽然严寒还没有收敛的意思,不过春天已经令人期待,微软近日提供了一款新鲜清爽的Windows 7主题《趣味水果》,这款主题中的壁纸来自独立玩家和图形设计师Guo Bo,从一种新颖独特的角度进入错综复杂的隐藏在水果深处的奇特世界。

    这款主题中仅包含6张壁纸,分辨率为1920X1200。

    壁纸图赏:

    clip_image001

    clip_image002

    clip_image003

    clip_image004

    clip_image005

    clip_image006

    官方下载:

    http://download.microsoft.com/download/C/D/B/CDB462D3-5DAE-4778-8A5B-D643ACC7337E/FunFruitGuoBo.themepack

  • 微软官方Win7主题《玫瑰》:情人节主题

    2012情人节将至,除了情人,情人节的另一个主角当属玫瑰了。玫瑰是爱情的象征,是情人眼中最妖娆的花儿。为了迎接即将到来的情人节,微软推出了Windows 7官方主题《玫瑰》。这款主题包含10张高清壁纸,分辨率为1920X1200,展现了多个品种玫瑰的风姿。

    壁纸图赏:

    clip_image001

    clip_image002

    clip_image003

    clip_image004

    clip_image005

    clip_image006

    clip_image007

    clip_image008

    clip_image009

    clip_image010

    官方下载:
    http://download.microsoft.com/download/A/7/4/A74FCE86-D537-4189-BCF3-853322DC0A1E/Roses.themepack

奇客罗方公众号 奇客罗方小程序 奇客罗方客服 ITGeeker Telegram

网站由ITGeeker技术奇客开发并管理;隶属于GeekerCloud奇客罗方智能科技
Site designed and developed by ITGeekerwhich is a sub-website of GeekerCloud
网站地图 | 沪ICP备2021031434号-4