archive.php child theme

Question

I am trying to implement an archive of all posts in my child theme as followsenter image description here

Currently I am playing with the following WP_Query which I put into archive.php in my child theme

<?php 
$archive_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?>
<?php if ( $archive_query->have_posts() ) : ?>

      <?php while ( $archive_query->have_posts() ) : $archive_query->the_post(); ?>
        <div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    <?php endwhile; ?>

    <?php wp_reset_postdata(); ?>

<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

My questions:

  1. Since the parent theme uses template parts with content.php and archive.php should I copy same folder structure into my parent theme( I know this is recommended approach) or I can just simply use archive.php in my child theme (Note: I also created categories.php and tags.php in my child theme to output those when user clicks on a link on single post view)

  2. How can I output the date as shown in my screenshot?

  3. I don’t want to create an archive page which gets added to the menu. I am just looking to add a link at the botton of the blog page (currently its index.php) saying ‘View Post Archives’. By clicking the link user would be taken to archives view as shown on my screenshot (Note: I checked Codex and the standard approach is to create a template and then apply it to empty page – in this scenario page gets added to the menu and this is not what I am looking for)

The above is just based on my research from Codex and some tutorials, however, if theres a simpler solution to implement the above certainly would appreciate sharing it with me

0
810311 3 years 2020-06-03T23:12:14-05:00 0 Answers 99 views 0

Leave an answer

Browse
Browse