I'm looking to add a formatted text at the bottom of each excerpt text when I read an archive page. The code is the same for all the posts.

I have found for the category based archive page by modifying the category.php file in my child theme folder. But i don't know where to write my code for the date based archive or for the all blog archive page of my theme.

Thank for your help.


Open archive.php from your theme's directory the code will look like this

Template Name: Archives
get_header(); ?>

<div id="container">
    <div id="content" role="main">

        <?php the_post(); ?>
        <h1 class="entry-title"><?php the_title(); ?></h1>

        <?php get_search_form(); ?>

        <h2>Archives by Month:</h2>
            <?php wp_get_archives('type=monthly'); ?>

        <h2>Archives by Subject:</h2>
             <?php wp_list_categories(); ?>

    </div><!-- #content -->
</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

the add your html code between

</div><!-- #content -->

Your code goes here .......

</div><!-- #container -->


upvote my answer i..

| improve this answer | |
  • How do you know the content of the themes archive.php page? I'm pretty sure it won't look like in your example... Do you think the theme files should be directly modified or do you think that a child theme should be used too? Bad answer... Hope you don't do this for a living on clients websites... – Mat Mar 19 '18 at 23:27
  • I agree with Matthew If I create an archive.php from scratch, it doesn't give me the result I'm looking for, even if I paste the content given by amol – Jomus Mar 22 '18 at 16:03

You need to copy archive.php of parent theme and then paste into child theme. Now do your required changes into child theme's archive.php

| improve this answer | |
  • If I understand all of you, the first step is to locate the archive.php file. I use the Divi theme and I didn't find any archive.php in this theme. I try with index.php in the theme directory (just for a test) but it doesn't work. Someone could you explain me where is the archive.php ? Isn't a mandatory file for any theme ? Thank you. – Jomus Mar 22 '18 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.