简体   繁体   中英

add a sidebar to the Category archive pages in wordpress

Is it possible to add a sidebar to the Category, Tag and search results archive pages?

Thanks!

The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme's directory from the following list:

For Category:-

 1. category-slug.php
 2. category-ID.php
 3. category.php
 4. archive.php
 5. index.php

For Tag:-

1. tag-slug.php
2. tag-id.php
3. tag.php
4. archive.php
5. index.php

If you don't have one, use archive.php , and so on.

For Search Result:-

 1. search.php

This is not a Search Page, it is merely a template that displays the search results.

And add use this below code for sidebar. put below code in file where you want to display sidebar. This is default sidebar

<?php get_sidebar(); ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM