[Resolved] Creating archive page

Home Forums Support [Resolved] Creating archive page

Home Forums Support Creating archive page

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #148548
    Mathijs Kooij

    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.

    #148563
    Tom
    Lead Developer
    Lead Developer

    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?

    #148582
    Mathijs Kooij

    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.

    #148592
    Tom
    Lead Developer
    Lead Developer

    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?

    #148595
    Mathijs Kooij

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

    #148701
    Tom
    Lead Developer
    Lead Developer

    No problem πŸ™‚

    #148842
    Mathijs Kooij

    Hello, I made a screenshot what I mean:

    https://www.dropbox.com/s/h7flje5mtu1roi6/archivepage.png?dl=0

    I hope you can help me.

    #148995
    Tom
    Lead Developer
    Lead Developer

    Ah yea, GP doesn’t have an option like this.

    However, you may be able to use a plugin like this to display posts from certain categories, dates etc..
    https://wordpress.org/plugins/display-posts-shortcode/

    What theme were you using previously?

    #149019
    Mathijs Kooij

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

    #149096
    Tom
    Lead Developer
    Lead Developer

    Let me know if you need any tips πŸ™‚

    #149150
    Mathijs Kooij

    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();

    #149182
    Tom
    Lead Developer
    Lead Developer

    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();
    #149288
    Mathijs Kooij

    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();

    #149516
    Tom
    Lead Developer
    Lead Developer

    Ah yea, my bad. I adjusted my code above as well which should work now πŸ™‚

    #149526
    Mathijs Kooij

    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.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.