0

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.

1

2 Answers 2

1

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

<?php
/*
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>
        <ul>
            <?php wp_get_archives('type=monthly'); ?>
        </ul>

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

    </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..

2
  • 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
    Commented Mar 19, 2018 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
    Commented Mar 22, 2018 at 16:03
0

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

1
  • 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
    Commented Mar 22, 2018 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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