你如何在wordpress中交换样式表?

时间:2014-10-22 10:16:23

标签: wordpress unique stylesheet

首先,我已经阅读了有关应用特定于页面的样式表的几个问题。我的问题是我有几个页面只需要独特的样式表。标题包含用于大多数页面的样式表,因此我需要将其替换为这些页面上的唯一页面。

不知道我做错了什么:

 <?php if ( is_page('unique_page') ) {
            wp_enqueue_style( '<?php bloginfo('template_url'); ?>/unique_stylesheet.css' );//page-specific css for unique page
           }
       else {wp_enqueue_style( '<?php bloginfo('stylesheet_url'); ?>' ); //default stylesheet

 } ?>

使用header.php中的此代码重新加载页面时,页面为空白。 如果那不是正确的方法,还有什么呢?我再次不想为唯一页面加载默认的css,只加载页面特定的样式表。

1 个答案:

答案 0 :(得分:1)

您应该在主题的functions.php中使用add_action( 'wp_enqueue_scripts', 'customstyles' );

function customstyles() {
 if ( is_page('unique_page') ) {
            wp_enqueue_style( bloginfo('template_url').'/unique_stylesheet.css' );//page-specific css for unique page
           }
       else {wp_enqueue_style( bloginfo('stylesheet_url') ); //default stylesheet

}
相关问题