WP在body标签内渲染HTML

不知道它是太基础还是太复杂。有人可以在WordPress <body>标签上呈现一些HTML吗?

这是一个例子。

在正常的HTML情况下, 你要做的就是在” body”标记内添加任何内容, 它将显示在页面源代码中。类似于<body itemscope itemtype =(后跟架构类型)>

但是WordPress并非如此。有人可以帮我吗?我对HTML, CSS和WordPress有一些基本的了解。


#1


一种方法是:-编辑header.php并将这些属性添加到正文中。

另一种方法(不编辑主题文件)是创建一个插件, 该插件添加一个将这些属性添加到主体的js。像这样的东西:

$("body").attr( { data-spy:"scroll", data-target:".navbar" } );

编辑查看Sevi的答案后。最合适的方法是

function wp_body_classes( $classes )
{
    $classes[] = '" spy="scroll" data-target=".navbar';

    return $classes;
}
add_filter( 'body_class', 'wp_body_classes', 999 );

来源:

https://www.srcmini02.com/63845.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37561.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?