如果有人能幫助我,我會很感激。 我知道這是一個非常頻繁的問題,但是我花了好幾天的時間看着其他人的帖子,試圖解決如何使用我的函數文件夾將自定義樣式錶鏈接到我正在處理的頁面模板。如何將自定義樣式錶鏈接到頁面模板?
到目前爲止,我發現,看起來最有可能的工作的代碼是這一個 -
if(is_page_template('work.php')) {
wp_register_style("work-style", get_template_directory_uri() .
"/css/page-template.css", '', '1.0.0');
wp_enqueue_style('page-template');
}
我試圖創建的頁面模板被稱爲「工作」,因爲我已經試圖添加到代碼中,但是我正在做的事情是不正確的,因爲它要麼使用主樣式表,要麼沒有任何效果,留下頁眉和頁腳之間的空白頁面。
您可以在下面看到我的頁面模板php的代碼。 (我對wordpress和一般編碼都很陌生,所以如果我犯了一些愚蠢的錯誤,請告訴我)。我開發了我從頭開始使用的主題。
<?php
/*
Template Name:work
*/
?>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet"
type="text/css">
<body>
<?php get_header(); ?>
<div class="content" id= "workcontent">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<div class="entry">
<?php the_content(__('Read the rest of this entry »', 'kubrick')); ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<div id="wrapper">
<a href="/landscapes"><div class="albums" id= "album1"></div></a>
<a href="/seascapes"><div class="albums" id= "album2"></div></a>
<a href="/macro"><div class="albums" id= "album3"></div></a>
<a href="/cities"><div class="albums" id= "album4"></div></a>
<a href="/long-exposure"><div class="albums" id= "album5"></div></a>
<a href="/miscellaneous"><div class="albums" id= "album6"></div></a>
</div>
</div>
</body>
<?php get_footer(); ?>
嗨德米特里,我都嘗試,可惜他們都沒有工作。函數文件夾是我最想要放置代碼的位置,但是當我將第一條建議放在那裏時,它提出了消息 「警告:call_user_func_array()期望參數1是有效的回調函數' lwh_scripts'找不到或函數名無效/var/sites/l/lucieaverill.co.uk/public_html/wp-includes/plugin.php on line 496「 你知道這意味着什麼嗎? 較短的代碼只顯示在頁面頂部。 – Jack1991
我的錯誤,複製和粘貼錯誤,用enqueue_styles代替lwh_scripts – Dmitriy
對於短代碼,用php標籤包裝它: <?php代碼在這裏?> – Dmitriy