Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress using index.php instead of archive.php

My understanding from reading the WP template hierachy was that when I set my a page as my posts page in settings > reading settings that Wordpress should use archive.php. Instead it uses index.php.

Obviously I could just put my code in index.php and my site will work. But it doesn't seem like best practice, and I can't find any documentation of best (or good) practice.

Why doesn't Wordpress use archive.php in this circumstance?

And would using index.php as my posts page have unintended consequences?

Note: I've been using the _s theme as a base, but I've had the same problem with no theme base or parent.

like image 805
jay_aye_see_kay Avatar asked Dec 07 '17 04:12

jay_aye_see_kay


People also ask

What is archive php in WordPress?

The archive. php template is used to display monthly, category, tag, author, and other archive pages. Our custom archives page would be a single page that will bring all of your other archives together.

What is index php used for in WordPress?

Required Files As mentioned earlier in the “What is a Theme” section, the only files needed for a WordPress theme to work out of the box are an index. php file to display your list of posts and a style. css file to style the content.

How do I open index php in WordPress?

Log in to the WordPress Admin interface. In the left sidebar, hover over Appearances, then click Theme Editor. In the right sidebar, click functions. php.

How do I edit an index php file?

Yes , you can modify from appearance -> editor, At right side you will get index. php , click on that file name so it will open in editor to modify.


1 Answers

you want to use home.php instead of archive.php as it is blog posts index page (set in WordPress Settings -> Reading). It is also in hierarchy on the third position from bottom.

like image 67
DanijelSVK Avatar answered Sep 22 '22 01:09

DanijelSVK