Site logo

Archived topic

Creating archive page

15 replies · Started by Mathijs Kooij on October 29, 2015

Viewing posts 1–15 of 16

I used an other theme before and could just choose the page template archive for a paga and there it was! With GP I see no page templates and no way to create an archive for searching.

Hi there,

All archive pages are built automatically by WordPress.

Are you wanting some sort of custom template for your archives? If so, what kind of layout are you wanting to achieve?

Ok, maybe I am missing something, how do I create this archive. On my last theme I just created an empty page, set the template to archive and it was there.

What did your last archive display? All of your posts? Specific ones?

WordPress creates archive pages by default by date, categories, tags etc..

Best way to find them is to use the "Archives" widget in "Appearance > Widgets".

However, maybe your old archive displayed something differently?

Thank you, i will install the old theme and make a screencap tomorrow. For now thank you for your great help.

No problem :)

Thanks I will look into this, maybe even some better plugin. My last theme was evermore from pexeto.

Let me know if you need any tips :)

Thank you. I created a child theme (for some other options also).

Made a new page-archive.php in this and based it on page.php. It works now (code is below), but styling is all wrong, not enough experience. Could you look into it and see what goes wrong? The page I use it for is:
https://bestevaer.org/nieuws/archief/

<?php
/*
Template Name: Archives
*/
get_header(); ?>

>
<main id="main" <?php generate_main_class(); ?>>
<?php do_action('generate_before_main_content'); ?>

<?php the_post(); ?>

<?php get_search_form(); ?>

<h2>Archieven per maand:</h2>

    <?php wp_get_archives('type=monthly'); ?>

<h2>Archieven per onderwerp:</h2>

    <?php wp_list_categories(); ?>

<h2>Archieven per Auteur:</h2>

    <?php wp_list_authors('show_fullname=1&optioncount=1&orderby=post_count'); ?>

<h2>Alle pagina's:</h2>

    <?php wp_list_pages('title_li='); ?>

<!-- #content -->

<!-- #container -->

<?php while ( have_posts() ) : the_post(); ?>

<?php get_template_part( 'content', 'page' ); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) : ?>

<?php comments_template(); ?>

<?php endif; ?>

<?php endwhile; // end of the loop. ?>
<?php do_action('generate_after_main_content'); ?>
</main><!-- #main -->

<!-- #primary -->

<?php
do_action('generate_sidebars');
get_footer();

You'd want to do something like this:

<?php
/*
Template Name: Archives
*/
get_header(); ?>

	<div id="primary" <?php generate_content_class();?>>
		<main id="main" <?php generate_main_class(); ?>>
			<?php do_action('generate_before_main_content'); ?>
			<?php while ( have_posts() ) : the_post(); ?>

				<?php the_post(); ?>
				
				<?php get_search_form(); ?>
				
				<h2>Archieven per maand:</h2>
				<ul>
					<?php wp_get_archives('type=monthly'); ?>
				</ul>
				
				<h2>Archieven per onderwerp:</h2>
				<ul>
					 <?php wp_list_categories(); ?>
				</ul>
				<h2>Archieven per Auteur:</h2>
				<ul>
					 <?php wp_list_authors('show_fullname=1&optioncount=1&orderby=post_count'); ?>
				</ul>
				<h2>Alle pagina's:</h2>
				<ul>
					<?php wp_list_pages('title_li='); ?>
				</ul>		

			<?php endwhile; // end of the loop. ?>
			<?php do_action('generate_after_main_content'); ?>
		</main><!-- #main -->
	</div><!-- #primary -->

<?php 
do_action('generate_sidebars');
get_footer();

Thanks, but that did not work, not the complete syteling. I took the 404 page as a base and edited it. New code:
<?php
/*
Template Name: Archives
*/
get_header(); ?>

>
<main id="main" <?php generate_main_class(); ?>>
<?php do_action('generate_before_main_content'); ?>

<?php do_action( 'generate_before_content'); ?>
<header class="entry-header">
<h1>Archieven</h1>
</header><!-- .entry-header -->
<?php do_action( 'generate_after_entry_header'); ?>

<?php get_search_form(); ?>
<h2>Archieven per maand:</h2>

    <?php wp_get_archives('type=monthly'); ?>

<h2>Archieven per onderwerp:</h2>

    <?php wp_list_categories(); ?>

<h2>Archieven per Auteur:</h2>

    <?php wp_list_authors('show_fullname=1&optioncount=1&orderby=post_count'); ?>

<h2>Alle pagina's:</h2>

    <?php wp_list_pages('title_li='); ?>

<!-- .entry-content -->
<?php do_action( 'generate_after_content'); ?>

<!-- .inside-article -->
<?php do_action('generate_after_main_content'); ?>
</main><!-- #main -->

<!-- #primary -->

<?php
do_action('generate_sidebars');
get_footer();

Ah yea, my bad. I adjusted my code above as well which should work now :)

Thank you, but with my code I get the normal page (so it looks like al the other ones) with your adjusted code I get a full-screen page, I lose a part of the styling. For now I stick with the modified 404 pages, that works fine. Thanks for your help.

This archived topic is closed to new replies.