小编FRQ*_*692的帖子

以编程方式创建类别和多个子类别

此代码在 wordpress 管理区域中正确显示类别。但不显示子类别。

我需要为每个类别显示 3 个类别和 3 个子类别?

这是我希望为每个类别提供的内容:

A类

  • 子类别 1
  • 子类别 2
  • 子类别 3

我在 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)

php wordpress categories

3
推荐指数
1
解决办法
5003
查看次数

在wordpress主题中将the_post_thumbnail添加为CSS背景

我正在尝试将我的特色图像设置为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)

css php wordpress

2
推荐指数
1
解决办法
2773
查看次数

标签 统计

php ×2

wordpress ×2

categories ×1

css ×1