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

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中以不同的方式设置类别的样式。

How to style categories differently in 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。

Creating a template for individual category in your WordPress theme

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类。

Category class added to body element by WordPress

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类中的类别名称。

Changing category style using 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视频教程。 您也可以在TwitterFacebook上找到我们。

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

wordpress后台样式

ERR_TOO_MANY_REDIRECTS错误是指在访问WordPress后台时出现的错误提示,表示重定向次数过多。这个错误通常是由于配置问题或者服务器设置引起的。解决这个问题的方法有几种。 一种方法是检查WordPress设置。确保在WordPress设置中,网站的URL和站点地址都正确设置为你的域名。还可以尝试禁用所有插件,然后逐个重新启用插件,以确定是哪个插件引起了重定向问题。 另一种方法是检查服务器的设置。首先,确保你的网站的域名已经正确指向服务器,并且服务器的配置文件中没有重定向规则。另外,还可以尝试删除服务器上的缓存文件或者重启服务器来清除任何可能引起重定向问题的缓存。 如果以上方法都没有解决问题,还可以尝试修改WordPress的配置文件。通过FTP或者文件管理器找到WordPress的根目录下的wp-config.php文件,添加以下代码: define('WP_HOME','http://yourdomain.com'); define('WP_SITEURL','http://yourdomain.com'); 将上面的代码中的"yourdomain.com"替换为你的域名。保存文件后,重新访问WordPress后台,看看是否问题已经解决。 总之,ERR_TOO_MANY_REDIRECTS错误可能是由于WordPress的配置问题或者服务器设置引起的。通过检查WordPress设置、服务器的设置和修改WordPress的配置文件,你应该能够解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [解决安装wordpress时出现ERR_TOO_MANY_REDIRECTS重定向次数过多问题 原创</font>](https://download.csdn.net/download/weixin_38677648/12900397)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Nginx + WordPress ERR_TOO_MANY_REDIRECTS](https://blog.csdn.net/cyan20115/article/details/106548984)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值