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?
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)
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.
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.
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
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.
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
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.
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.
@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.