WordPress.org

Forums

Frontier
[resolved] Post Archive Index (4 posts)

  1. KylcMc
    Member
    Posted 1 year ago #

    I working on putting together a site for my local Historical Society. We have hundreds of post in categories and would like to display archives of just the post title (with link to post) and date. Only want this for when a user views post by category or dates rather than showing the entire post to them. From what I have researched I could use an archive template to do so however with out much knowledge of programming I'm lost on where to start. Any help?

  2. KylcMc
    Member
    Posted 1 year ago #

    After more googling and lots of reading I've got a start I think. I've started by modifying index.php to make a call to a new loop file for the archive and duplicating loop-blog.php to loop-archive.php. So far that is working as I've made a few test changes to my new file (loop-archive.php) to see if it is being called.

    Now I'm stuck at page formatting. I want the output to look similar to a page with just a list of the post titles, date, author.

    Updated excerpt from index.php

    <!-- Start the Loop -->
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
      <?php if ( is_category() || is_tag() || is_date() ) : ?>
        <?php get_template_part( 'loop', 'archive' ); ?>
      <?php elseif ( !is_singular() ) : ?>
        <?php get_template_part( 'loop', 'blog' ); ?>
      <?php else : ?>
        <?php get_template_part( 'loop', 'single' ); ?>
      <?php endif; ?>
    <?php endwhile; else: ?>
  3. ronangelo
    Member
    Theme Author

    Posted 1 year ago #

    You shouldn't edit the theme files without using a child theme. You know what happens if you don't use one, right?

    To achieve what you're after, you could just copy index.php to your child theme folder then rename it as archive.php.

    Then change the loop to something like this:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class('blog-view'); ?>>
       <header class="entry-header cf">
          <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php echo the_title(); ?></a></h2>
          <div class="entry-date"><?php the_time(get_option('date_format')); ?></div>
          <div class="entry-author"><?php the_author_posts_link(); ?></div>
       </header>
    </article>
    
    <?php endwhile; else: ?>
  4. KylcMc
    Member
    Posted 1 year ago #

    No I don't, but I can only assume resulting in something unfavorable. So I shall look at the child theme direction then. Thanks for the loop suggestion I'll try that out after I remove the files I edited, upload the originals, and research the child theme direction.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.