October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Block Themes

How to Add a Custom Header, Footer, or Sidebar to WordPress Category Pages

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The correct method depends on your active theme. In a block theme, edit the category template in Appearance > Editor and arrange template-part, group, column, and archive blocks. In a classic theme, create or edit a category PHP template—usually category-{slug}.php for one category or category.php for all categories—and load shared files with get_header(), get_sidebar(), and get_footer().

First identify your theme type

Open the WordPress dashboard and inspect the Appearance menu. A block theme uses the Site Editor to manage headers, footers, templates, and blocks. A classic theme generally uses PHP template files and may provide Widgets and the Customizer instead. The menus and template names can vary by WordPress version and theme.

  • Appearance > Editor with templates and template parts indicates a block-theme workflow.
  • Theme files such as header.php, sidebar.php, footer.php, and category PHP templates indicate a classic-theme workflow.

How category template selection works

WordPress uses a template hierarchy, choosing the most specific available category template before falling back to broader archive templates.

Block-theme hierarchy

  1. category-{slug}.html for one category, such as category-news.html.
  2. category-{id}.html for one category by numeric ID.
  3. category.html for category archives generally.
  4. archive.html, then index.html, as broader fallbacks.

Classic-theme hierarchy

  1. category-{slug}.php for one category.
  2. category-{id}.php for one category by ID.
  3. category.php for all category archives.
  4. Broader archive templates and finally index.php if no category-specific file exists.

Use the slug-specific file when only one category needs a different layout. Use the general category template when every category should share the change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Customize a category in a block theme

Open the category template

  1. Go to Appearance > Editor.
  2. Open Templates.
  3. Select the category template if it is listed. Depending on the theme, it may be called Category, Categories, or be represented by a more general archive template.
  4. To target one category, create or select a category-specific template when your theme and WordPress version expose that option.

Add or change the header

Use the template’s existing header template part when possible. A template-part block inserts a shared header maintained separately from the category layout:

<!-- wp:template-part {"slug":"header"} /-->

You can also place a Group, Site Logo, Navigation, Search, or other blocks directly in the template when the category needs a distinct arrangement. Editing a shared header template part changes it wherever that part is used, so edit the category template itself if the variation should be limited to category archives.

Add or change the footer

Insert the theme’s footer template part at the end of the template, or create a footer arrangement from blocks:

<!-- wp:template-part {"slug":"footer"} /-->

Typical footer content includes navigation, copyright text, contact details, and social links. A shared footer part affects all templates that use it; a category-only footer belongs inside the category template.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a sidebar area

Block themes do not require a separate sidebar.php file. Create a two-column layout with a Columns block, or use a Group block beside the archive content. Place the blocks needed for the category audience—such as Categories, Search, Latest Posts, navigation, or custom text—in the secondary column. Keep the main post-list column and sidebar in a logical reading order on narrow screens.

Arrange the archive content

Use the Query Loop or Post Template blocks for posts, along with Archive Title and Term Description blocks where available. You can move the title, description, post list, and sidebar to control their visual order without changing the category’s posts.

Save, preview, and understand where the change lives

Save the template, then open the category archive on the front end in a logged-out window or private browser tab. Changes saved through the Site Editor are stored in the site’s database and take precedence over the theme’s bundled template files. If the layout must travel with a distributed theme, copy the resulting block markup into the corresponding file in the theme’s /templates directory rather than relying only on the database-saved version.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Customize a category in a classic theme

Choose the right PHP file

Find the category’s slug or ID in the dashboard’s category editor. In a child theme, create category-{slug}.php for one category, or category.php for all category archives. A child theme keeps the override separate from the parent theme, so a parent-theme update is less likely to erase it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Teacher Record Book
  • Keep track of everything from attendance to test scores
  • Spiral bound
  • Measures 8-1/2" x 11"

Load the shared header, sidebar, and footer

A basic category template can call the site’s existing shared files and retain the theme’s normal loop:

<?php
get_header();
?>

<main class="category-archive">
    <header class="archive-header">
        <?php the_archive_title( '<h1>', '</h1>' ); ?>
        <?php the_archive_description( '<div class="archive-description">', '</div>' ); ?>
    </header>

    <?php if ( have_posts() ) : ?>
        <?php while ( have_posts() ) : the_post(); ?>
            <article>
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <?php the_excerpt(); ?>
            </article>
        <?php endwhile; ?>
        <?php the_posts_pagination(); ?>
    <?php else : ?>
        <p>No posts found.</p>
    <?php endif; ?>
</main>

<?php
get_sidebar();
get_footer();
?>

Use get_sidebar() for the default sidebar. A named sidebar loads a matching file, for example:

<?php get_sidebar( 'category' ); ?>

That call looks for sidebar-category.php. Place the call where the sidebar belongs in the theme’s layout, and use the theme’s existing wrapper classes or CSS conventions so the new area aligns correctly.

Keep the theme’s expected loop and pagination

Do not remove the query loop merely to add surrounding markup. Preserve the theme’s loop, pagination, escaping, and accessibility conventions where possible. Put custom headings, promotional panels, or category-only markup before or after the loop, then test categories with no posts as well as categories with many posts.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

SaleBestseller No. 4
Bestseller No. 5
Teacher Record Book
Teacher Record Book
Keep track of everything from attendance to test scores; Spiral bound; Measures 8-1/2" x 11"
$4.89

Which approach should you choose?

Decision Block theme Classic theme
Primary editing location Appearance > Editor, Templates, and blocks Child-theme PHP templates and template tags
One-category layout category-{slug}.html when supported category-{slug}.php
All category layouts category.html category.php
Shared header or footer Template-part block get_header() and get_footer()
Sidebar Group or Columns block in the template get_sidebar() or a named sidebar file
Where edits are stored Database when saved in the Site Editor; copy markup to /templates for a portable theme change Versioned theme files, preferably in a child theme
Best fit Visual editing and block-based layouts Developer-managed source and precise PHP control

Test before publishing

  • Open the exact category URL and confirm the intended header, footer, and sidebar appear.
  • Check another category to ensure a one-category override did not change every archive.
  • Test pagination, an empty category, long category names, and long descriptions.
  • Check the layout at narrow and wide viewport sizes; make sure the sidebar collapses or moves in a usable order.
  • Verify keyboard navigation, heading order, link labels, contrast, and that the post list remains readable without the sidebar.
  • If a template edit appears ineffective, check whether a more specific template, a saved Site Editor template, or a caching layer is taking precedence.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.