我有一个搜索结果页面,带有一个模板调用内容搜索。php。
基本上,这个文件的作用是在一个人在搜索栏上搜索某个内容后显示结果,我想编辑这个文件的css。
所以我尝试的是,我去函数。php并添加了如下常见代码
functions.php
function content_search_styles() {
if ( is_page_template( \'content-search.php\' ) ) {
wp_enqueue_style( \'page-template\', get_stylesheet_directory_uri(). \'/css/content-search.css\' );
}
}
add_action( \'wp_enqueue_scripts\', \'content_search_styles\' );
content-search.php
<article id="post-<?php the_ID(); ?>" <?php post_class(\'clearfix\'); ?>>
<h2>Search Results</h2>
<b>Results as following</b>
<?php the_title(\'<h1 class="entry-title">\',\'</h1>\' ); ?>
<?php if( has_post_thumbnail() ): ?>
<div class="pull-left"><?php the_post_thumbnail(\'thumbnail\'); ?></div>
<?php endif; ?>
<small><?php the_category(\' \'); ?> || <?php the_tags(); ?> || <?php edit_post_link(); ?></small>
<?php the_excerpt(); ?>
<hr>
</article>
content-search.css
body {
display:none !important;
}
CSS不会反映在搜索结果页面上,请再次建议并感谢您