通過function.php附加一個css文件,將下面的代碼添加到functions.php中。
(Recommaded不要使用function.php因爲它的主題具體)
<?php
function mypage_head() {
echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/includes/mypage.css">'."\n";
}
add_action('wp_head', 'mypage_head');
?>
方法使用了添加標題爲模板
<?php get_header(); ?>
創建的模板頁面在這裏:
<?php /* Template Name: CustomPageT1 */ ?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while (have_posts()) : the_post();
// Include the page content template.
get_template_part('template-parts/content', 'page');
// If comments are open or we have at least one comment, load up the comment template.
if (comments_open() || get_comments_number()) {
comments_template();
}
// End of the loop.
endwhile;
?>
</main><!-- .site-main -->
<?php get_sidebar('content-bottom'); ?>
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
你是否正在通過調用其他頁面中的'get_header()'來加載頁眉電子模板?因爲這也會加載您的樣式... –
在此處張貼您的自定義頁面。 –
get_template_part('template-parts/content','page'); <這解決了我的問題。謝謝 –