If page displays posts conditional

Both will do the same job in the end of the day. You can however improve on the first code.

is_archive() returns true on all archives page, which includes the following

  • taxonomy archive pages

  • category archive pages

  • date archive pages

  • author archive pages

  • tag archive pages

So, if you need to target all these pages, you can simply make use of is_archive().

ONE OTHER NOTE

is_single() returns true when is_attachment() return true as an attachment is also a single post. So be careful when using the second block of code when you need something different on attachment pages and normal single pages

IN GENERAL

There are a few things that I don’t get on your implementation. You can do what you need to do with the correct templates. You do not need conditionals

Look at the Template Hierarchy, and then look what you need to achieve. You only need 4 templates

  • For pages – Create page.php

  • For home, archive and search pages, create index.php. index.php is a fall back if the custom templates (like search.php or category.php) don’t exist. So WordPress will use index.php to show the homepage, archives and search result pages

  • For attachements, copy index.php and rename it attachment.php

  • For single posts, create single.php. This should be more than enough