Blog page same as Archive Default

I want my Blog Page to be the same as my Archive Template

But I can’t find a way to use conditions or anything to apply the archive template to my blog.

I guess I can copy and paste the archive template into my blog page directly, but I was wondering if there is something I am missing?

Here is an image of my current setup, where my Archive pages inherit the Query from URL (2)

and my Blog Page (1) is a custom template with a custom query element inside that queries for the posts post_type. I have assigned this template to my blog page

Is there any way I can have just the 1 template for blog + archives?

Hi @grantambrose,

The Index template will by default apply to the blog page and archives.

You can then add other templates with visibility conditions as needed to override for other page types.

thanks for taking a look at this one.

The main aim of this is to be able to edit the 1 template in cwicly and it affect my archives + blog page

that’s the issue I am facing. Currently I have:

  • index template (default across site)
  • archives template - affects all custom post types
  • but now I need to create a custom template and assign that on my blog page when editing my blog page, to then override the index template. The thing is, I am just copy and pasting my archive template into this template and I want them to be the same (edit in 1 place abilities)

I am proposing that instead of having the index template as the default for all pages, use it specifically for the archive pages.

Then create any additional templates you need and use Visibility conditions to specify how you want these to be applied to any other types of pages.

We have used this approach on the last 4 Cwicly websites and it has worked well.

1 Like

I do like @StrangeTech :slight_smile:

And I remember having troubles as well overiding templates at some time, and I found thid in WP dev docs:


You can clearly see here that your blog page will never use the archive.php template, but only home.php or index.php. Blog index page is not considered as an archive by WP.

And when I tried, I couldn’t overide this, even with Cwicly conditions. Index template seems to be forced on blog page.

What I find strange is that it seems we can’t create the home.php template in FSE (or Cwicly), so using the index.php template seems the way to go.

Check this thread:

1 Like

Perfectly illustrated @yankiara.

Amazing! I forgot that this was actually WordPress with a templating system :crazy_face:

Tomorrow I will do as StrangeTech said and change my templates around - thanks for that

I set it up this morning on my website with index.php being my archives

Then I created a new “single” template and used conditions to apply that to ‘posts’ and ‘pages’ and it works.

  1. But looking at that flowchart of the template hierarchy in WordPress, I thought single only affects posts and that I would need to create a template for page.php?

Or in cwicly, when we create a single template, are we creating a singular.php template and thats why setting our conditions to show per post type work.

Hope that makes sense

  1. With index now handling my archives, I have my single template set up assigned to pages and posts
    but now that overrides my Blog page (as its technically a page)

so I will now create a custom template and clone my archive layout into that, then assign this template on my blog page directly.

unless there is another way to do it?

Hi @grantambrose,

You can simplify this - here is a general example:

Use the index template for all archives with or without the following conditions (depending on your needs):

If you want the pages and posts to use different templates:

Create a “Page” template with the following conditions:

Create a “Single item: Post” template with the following conditions:

Else if you want the pages and posts to share a template:

Create a “Single” template with the following conditions:

If a template is being overridden you can increase its priority using the “Priority” field.

so just to confirm, you create a custom template that you assign to your blog page?

I made a video showing how I eventually got this to work how I want.

But maybe there is an easier way?

https://www.awesomescreenshot.com/video/18793582?key=dd9cd3155189250e0238903f28eb2d12

I saw in someone else’s post here in Discourse that they had the ability to exclude specific pages. I don’t seem to have that - was that removed or something?

for example, I can’t create a single template that applies to singular

  • posts
  • pages
  • exclude page ‘blog’

hence why I created a taxonomy with the term “blog” for pages, and used that in my exclusion rule

As mentioned:

This applies to all archives including the blog page, which as @yankiara mentioned:

From your video, it appears you are using the strategy we have described.

If you assign your blog page as the “Posts page” in the WordPress settings and don’t specify any visibility conditions for the index template, it should be used for the blog page.

From your descriptions it seems like you will be able to achieve everything with 2 templates.

The only other optimisation from your video is you can simplify your singular visibility conditions into one:

ahhhh you won’t believe it,

somewhere along the way Settings > Reading got unset. So I put back my posts page to my blog page and it’s all working

not sure how that happened but thanks again for your help with this one

Hope @grantambrose has figured it out, as it seems there’s a bit of confusion here regarding templating.

There’s no requirement to use the index.php for anything at all. You can, if you want, but you can choose not to. It’s a catch-all for any post type, post, archive, taxonomy, term, etc that has no other template defined in WP.

@StrangeTech’s proposed solution:

works, but will cause unwanted issues if you have other post types. It presupposes you only have posts and pages.

It would be safer to create the conditions for multiple post types like this:
image

Unless you absolutely want every single post type to share the same template design.

@owynter, there was no need for presuppositions, I was simply basing this on the information provided by @grantambrose.

I’ve said multiple times in different comments that any strategy should be tailored to his specific requirements, so this is a given.

I even provided screenshots showing how to do it if you wanted different templates based on the post type:

That said, it is completely reasonable having a simple catch all condition/template for singular as long as it fulfils the requirements of the site in exactly the same way as having a catch all condition/template for archives is used.

I’ll be brief, since it seems you perceived my comment as some form of attack and you felt the need to be defensive. That’s on you, really.

Your solution works fine, for that specific instance. But there was no clarification as to the circumstances. I felt like @grantambrose was still feeling his way through. Additionally, should another newbie user come across this, it would only show part of a bigger picture.

Not at all, there is no defensiveness, only clarification. I was simply replying as part of the conversation. Clearly you and I both value making websites and code that are adaptable and future proof.

I was merely pointing out that the same points you were bringing up were ones I had already highlighted earlier in the conversation (and therefore we are in agreement) and that screenshot I posted was a developed refinement of the already advanced conversation based on what @grantambrose had mentioned he needed.

I think this misunderstanding may be a demonstration of the inherent limitations of text-based communication.