I've made a child theme of Twenty Twenty theme and want to display the posts/ category archive pages in flexbox grid.

However, none of the conditional tags I'm hoping to check outside the loop (is_home, is_archive, is_category) are returning true on posts page or category archive pages:

* @since Twenty Twenty 1.0

<?php if ( is_archive() ): ?>
<?php endif; ?>
<?php if ( is_category() ): ?>
<?php endif; ?>
<?php if ( is_home() ): ?>
<?php endif; ?>

<main id="site-content maybe-flex-directive-class-here">


    if ( have_posts() ) {

        while ( have_posts() ) {

I expect either I'm missing something obvious or going about it the wrong way.

  • Which template file does this code reside in?
    – bosco
    Aug 11, 2022 at 1:29
  • it's in singular.php
    – MikeiLL
    Aug 11, 2022 at 1:41
  • which makes the answer really obvious! I wasn't seeing that the theme includes <main id="site-content"> on index.php as well as singular.php. I think I will delete this post unless you feel like posting an answer. Please lmk.
    – MikeiLL
    Aug 11, 2022 at 1:46
  • Naw that's cool - you can delete :P. Always keep our friendly template hierarchy close at hand!
    – bosco
    Aug 11, 2022 at 1:47
  • Thanks and peace man
    – MikeiLL
    Aug 11, 2022 at 1:56

1 Answer 1


I was going to (and actually did) delete this post, but after sleeping on it, think it might end up being of some use.

What I was missing, above, is [Template Hierarchy][1]. I was looking at the singular.php template file, which will only ever be loaded when is_archive(), is_home(), etc, aren't true.

What got me is that the HTML <main> element exists on both the index.php and singular.php documents in this theme.

So I was able to update the child theme's copy of index.php:

<main id="site-content" class="flex-container">

With CSS:

.flex-container {
  display: flex;
  flex-direction: column;
/* Responsive layout - make multi-column on larger screens */
@media (min-width: 800px) {
  .flex-container {
    flex-direction: row;

Thanks for the solution in the comment, @bosco.

  [1]: https://developer.wordpress.org/themes/basics/template-hierarchy/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.