1

我正在尝试让标题图像在某些类别页面上以不同方式显示。例如,足球运动员的图像将显示在所有具有足球类别的帖子上。

这也需要显示在存档页面上,所以我使用了条件标签

is_category('football') 

例如,这很好用。虽然它没有在实际的帖子页面本身上显示标题图像。有没有办法让我以某种方式完成这项工作?也许在某个地方还有另一个条件标签?

任何帮助将不胜感激。

4

1 回答 1

1

Actually in WordPress you can use a conditional tags in many ways. In your question you mentioned you want to check if it's in the category/archive page and you know that how to do it but in a comment you mentioned you want to check if a post belongs to a category and in this case it could be on a single post page.

To check in the single post page you can use

if(is_single() && in_category('football'))

You may check these links in_category, is_object_in_term and is_single.

于 2012-12-27T07:49:46.047 回答