【问题标题】:How to initialise CSS statements from the function.php file (Wordpress)?如何从 function.php 文件(Wordpress)初始化 CSS 语句?
【发布时间】:2010-12-19 19:31:32
【问题描述】:

我的 function.php 文件中有以下 CSS 条件语句:

 function logo_exists() {
 global $options;
    ?><style type="text/css">
  #header h1 a {
  <?php
  if ( $options['logo'] == NULL ) { ?>
      float: left;
   text-indent: 0;
  <?php } else { ?>
   background: url(<?php echo $options['logo']; ?>) no-repeat scroll 0 0;
   float: left;
   text-indent: -9999px;
   width: 160px;
   height: 80px;
  }
  <?php } ?>
    </style><?php
}

示例:

        (...same code as above...)

       width: 160px;
       height: 80px;
      }
      <?php } ?>
        </style><?php

        add_option('logo_exists');

}

我不确定如何“添加”或“初始化”它。

我试过了:add_option('logo_exists');和 add_action('logo_exists');但它没有用。

function.php 文件中的条件 CSS 语句的 Wordpress“添加”命令是什么?

【问题讨论】:

标签: wordpress function


【解决方案1】:

您可以使用 wordpress 条件,而不是使用这种变体: is_home()is_singular()(页面/文章)is_single()is_page()广告等等。

除此之外,WP 会自动向 body 元素添加一个额外的类,您可以将其关联起来以构建您的 css 选择器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-19
    • 1970-01-01
    • 2011-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多