此代码在 wordpress 管理区域中正确显示类别。但不显示子类别。
我需要为每个类别显示 3 个类别和 3 个子类别?
这是我希望为每个类别提供的内容:
A类
我在 wordpress 主题的 functions.php 文件中添加了以下代码:
//create the main category
wp_insert_term(
// the name of the category
'Category A',
// the taxonomy, which in this case if category (don't change)
'category',
array(
// what to use in the url for term archive
'slug' => 'category-a',
));`
Run Code Online (Sandbox Code Playgroud)
然后对于每个子类别:
wp_insert_term(
// the name of the sub-category
'Sub-category 1',
// the taxonomy 'category' (don't change)
'category',
array(
// …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的特色图像设置为CSS中的背景图像.
我需要在HTML和CSS中的两个位置显示相同的特色图像.
你如何the_post_thumbnail()
在CSS中使用?
HTML
<div class="magnify">
<div class="large"></div>
<img class="small" <?php the_post_thumbnail( 'large', array
('class' =>'img- responsive') ); ?> />
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.large {background: url('img/image.jpg') no-repeat;}
Run Code Online (Sandbox Code Playgroud)