以编程方式或静态方式将自定义属性添加到Wordpress主题标记中

时间:2015-05-02 23:47:43

标签: wordpress casting chromecast video.js

我正在我的Wordpress网站上实现VideoJS Chromecast插件,并且在我的生活中,无法弄清楚如何将自定义属性添加到主题的<html>标记中,如下所示:

<html data-cast-api-enabled="true">

我看过主题的wp-header.php和wp-page.php,但我无法想象我可以插入这个特定属性的位置。我会以编程方式使用脚本或静态输入PHP代码。我是WP的新手,我曾经随意编写我的Joomla主题的index.php。

我还安装了插件example,他们的演示版index.html与使用VideoJS播放器实例的Cast图标一起播放得很好。我使用Chrome内置调试器可以看到的唯一区别是该标签中没有设置该属性,而VideoJS使用&#34; Cast API不可用来响应。正在重试...&#34 ;.我没有看到其他JS或CSS错误。

有没有人想到这个?

非常感谢! 相对论

2 个答案:

答案 0 :(得分:0)

在左侧的“Appearance”下,然后是“Editor”,然后在主题内应该是一个简单的“header.php”文件,它实际上是每个wordpress页面的html的第一部分。

看起来应该是这样的:

<?php /**
 * The Header for this theme.
 * A bunch of theme info here
 */ ?>
<!DOCTYPE html>
<!-- Here is the first HTML tag for the page -->
<html <?php language_attributes(); ?>>
<head>
<!--... more html and php code follows...-->

答案 1 :(得分:0)

感谢@zarazha领导。

我碰巧使用Theme.co的X主题,它有4个子主题。所有子主题都引用“全局”或父主题。我去了父母的“_header.php”并找到了上面的内容。

更确切地说:

<!DOCTYPE html>
<!--[if IE 9]><html class="no-js ie9" <?php language_attributes(); ?>><![endif]-->
<!--[if gt IE 9]><!--><html class="no-js" <?php language_attributes(); ?>><!--<![endif]-->

<head>
  <meta charset="<?php bloginfo( 'charset' ); ?>">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?php wp_title(''); ?></title>
  <link rel="profile" href="http://gmpg.org/xfn/11">
  <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
  <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

  <?php do_action( 'x_before_site_begin' ); ?>

  <div id="top" class="site">

非常感谢。 StackOverflow真棒! ;)

相关问题