wordpress后台样式

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

您要在WordPress中为类别设置不同的样式吗? 大多数WordPress主题对所有类别存档页面使用相同的样式。 但是,如果您运行内容丰富的网站,则可以对每个类别进行不同样式的设置,以最大程度地发挥其潜力。 在本文中,我们将向您展示如何轻松地在WordPress中以不同的方式设置类别的样式。

为什么在WordPress中以不同的样式设置类别? (Why Style Categories Differently in WordPress?)

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

如前所述,大多数WordPress主题为每个类别存档页面使用相同的模板。 那是因为主题开发人员不知道您将如何使用网站上的类别以及这些类别将是什么。

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

但是,如果您正在运行内容丰富的网站,那么更改类别存档页面的布局可能会对用户与该页面上的内容进行互动的方式产生重大影响。

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

例如,如果您运行一个新闻或杂志网站 ,则可以在本地新闻类别中显示本地广告。 您可以显示天气信息, 显示该类别中最受欢迎的故事 ,等等。

Having said that, let’s see how to easily style individual categories differently in WordPress.

话虽如此,让我们看看如何轻松地在WordPress中以不同的方式设置各个类别的样式。

在WordPress中以不同的方式设置单个类别的样式 (Styling Individual Categories Differently in WordPress)

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

在WordPress中有多种样式设置样式。 我们将向您展示两种不同的样式样式方法,您可以选择最适合您的需求和技能水平的一种方法。

在WordPress主题中使用单一类别模板 (Using Single Category Template in WordPress Theme)

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

WordPress主题遵循标准模板层次结构。 根据模板文件名,WordPress可以自动选择正确的模板来显示页面。

For example, it looks for category.php file to display category archive pages.

例如,它将查找category.php文件以显示类别存档页面。

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

WordPress还允许您为各个类别创建模板。 假设您要为“ Apple”类别设置不同的样式。 您可以通过在主题中添加一个新的模板文件并将其命名为category-apple.php来实现。

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

使用FTP客户端连接到您的WordPress网站,然后转到/ wp-content / themes / your-current-theme /文件夹并创建一个新文件category-apple.php。 不要忘记用您自己的类别名称替换apple。

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

您可以使用主题的category.php文件作为起点。 只需编辑并复制其所有内容。 现在,编辑新创建的category-apple.php文件,并将代码粘贴到其中。

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

之后,您可以开始对您的单个类别模板进行更改。 您可以为此类别创建和使用其他侧边栏 ,将其设置为全角页面 ,添加欢迎消息或其他所需的内容。

使用CSS在WordPress中设置单个类别的样式 (Style Individual Categories in WordPress Using CSS)

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

WordPress会自动将CSS类添加到整个网站的不同元素中。 这些包括身体课和岗位课。

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

例如,如果您查看类别存档页面,然后使用“检查工具” ,则会在body标签中注意到类别和类别名称CSS类。

You can use this CSS class to style each individual category differently by adding custom CSS.

您可以使用此CSS类通过添加自定义CSS来为每个单独的类别设置不同的样式 。

Here is some example CSS that you can use as a starting point.

这是一些示例CSS,您可以将其用作起点。


body.category-apple {
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site {
background:#232323;
}
.category-apple a {
color:#CCCCCC;
}

Don’t forget to change the category name in the CSS class with your own category name.

不要忘记使用您自己的类别名称更改CSS类中的类别名称。

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

我们希望本文能帮助您学习如何在WordPress中以不同的方式设置类别的样式。 您可能还希望查看我们的WordPress最受欢迎类别的黑客和插件列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-themes/how-to-style-individual-categories-differently-in-wordpress/

wordpress后台样式

wordpress后台样式_如何在WordPress中以不同的方式设置单个类别的样式相关推荐

  1. wordpress标签云_如何在WordPress中建立更好的标签云

    wordpress标签云 Once you've defined a great set of tags for your WordPress posts (or pages), you'll wan ...

  2. wordpress添加媒体_如何在WordPress中添加jQuery FAQ手风琴

    wordpress添加媒体 Recently one of our users asked us if there was a way for them to add a FAQ accordion ...

  3. wordpress添加媒体_如何在WordPress中添加社交媒体共享计数小部件

    wordpress添加媒体 Earlier on this blog, we created a Social Media Cheat Sheet for WordPress, but that on ...

  4. wordpress图像大小_如何在WordPress中添加图像积分(逐步操作)

    wordpress图像大小 Recently, some of our readers asked us about how to properly add image credits in Word ...

  5. wordpress添加媒体_如何在WordPress中添加新帖子并利用所有功能

    wordpress添加媒体 Are you trying to create a new post in WordPress? Do you want to learn about all the W ...

  6. wordpress添加媒体_如何在WordPress中添加精选内容滑块

    wordpress添加媒体 Do you want to add a featured content slider like Yahoo or ESPN? Many popular sites us ...

  7. wordpress谷歌字体_如何在WordPress中添加Google Maps

    wordpress谷歌字体 You can add all kind of content into your WordPress site. At WPBeginner we have shown ...

  8. wordpress默认密码_如何在WordPress中为新用户设置默认管理员配色方案

    wordpress默认密码 One of the most talked about feature of WordPress 3.8 is the new admin interface. It i ...

  9. wordpress添加媒体_如何在WordPress中添加电子书下载

    wordpress添加媒体 Do you want to add ebook downloads to your WordPress site? WordPress makes it easy for ...

  10. wordpress谷歌字体_如何在WordPress帖子编辑器中添加Google字体

    wordpress谷歌字体 Fonts are one of the most important aspects of your WordPress blog, and in case you di ...

最新文章

  1. 在 ASP.NET 上实现锁定表头、支持滚动的表格的做法
  2. Python读取文件内容为字符串的方法(多种方法详解)
  3. java groovyshell_在java中使用groovy怎么搞
  4. bdf比特数字基金_第四届世界数字经济大会,比特元BTY作为协办方参与
  5. Python:数据结构(list, tuple, Dict Set)
  6. (三)java版spring cloud+spring boot 社交电子商务平台 - Spring Cloud集成项目简介
  7. vue 高德地图使用热力图
  8. MATLAB----小波去噪
  9. js实现简单的有序map
  10. android自动适应横屏,Android屏幕适配(一)--自定义View屏幕适配
  11. 宝塔面板专业版企业版教程 纯手动 带原版脚本 插件免费用
  12. 云讯健身管理系统-9
  13. linux基础知识全面总结,51CTO博客-专业IT技术博客创作平台-技术成就梦想
  14. RK3588 Android12 SDK 中在device介绍及如何新建自己的产品lunch项
  15. 差分函数(差分运算)
  16. word中设置奇偶页页眉页脚
  17. python爬取2345天气网上2011年-2018年历史天气
  18. 输入年份判断是不是闰年
  19. 最新Teradata Database 15数据库将跨越大数据鸿沟
  20. 常规串口驱动CH340的安装

热门文章

  1. oracle取差集效率如何,Oracle Minus 取差集
  2. Untracked Files Prevent Checkout (AndroidStudio切换分支报错)
  3. Resource temporarily unavailable
  4. BZOJ1577 [Usaco2009 Feb]庙会捷运Fair Shuttle
  5. 浅谈深度信念网络(Deep Belief Network)
  6. svn代码被clean up了怎么找回来
  7. 台式计算机mac地址查询,计算机mac地址查询
  8. 【逻辑思考】有时评论比内容更精彩
  9. 支付宝崩了登上微博热搜
  10. 基于Barra多因子模型的组合权重优化