web-dev-qa-db-fra.com

the_excerpt (); la balise ne fonctionne pas

J'ai un problème avec la balise the_excerpt(); que j'utilise dans mon propre thème dans les fichiers index.php et archive.php. Le code est ci-dessous:

index.php

<?php get_header(); ?>
<section class="center-column">
<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
     <!--<?php echo the_permalink(); ?>-->
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header>
            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <div class="post-date"><?php the_time(get_option( 'date_format' )); ?></div>
        </header>
        <?php the_excerpt(); ?>
        <footer class="post-footer">
            <div class="categories">Posted in: <?php the_category(', '); ?></div>
            <div class="tags">Tags: <?php the_tags(); ?></div>
        </footer>
    </article>
    <?php endwhile; ?>
    <section class="post-navigation">
        <div class="alignleft">
            <?php next_posts_link('&laquo; Older Entries') ?>
        </div>
        <div class="alignright">
            <?php previous_posts_link('Newer Entries &raquo;') ?>
        </div>
    </section>
<?php else : ?>
    <article>
        <h3>Not Found</h3>
        <p>Sorry, but you are looking for something that is not available</p>
    </article>
<?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

archive.php

<?php get_header(); ?>

<section class="center-column">
    <!-- Archive Heading -->
    <section>
        <h3 id='archive-heading'>
            <?php if (is_category()) { ?>
            Archive for the '<?php single_cat_title(); ?>' Category
            <?php } elseif (is_tag()) { ?>
            Posts Tagged '<?php single_tag_title(); ?>'
            <?php } elseif (is_month()) { ?>
            Archive for <?php echo get_the_date('F Y'); ?>
            <?php } ?>
        </h3>
    </section>
    <!-- End Archive Heading -->

    <!-- Post Excerpt -->
    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <header>
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <div class="post-date"><?php the_time(get_option( 'date_format' )); ?></div>
                </header>
                <?php the_excerpt(); ?>
                <footer>
                    <div class="categories">Posted in:
                        <?php the_category(', '); ?>
                    </div>
                    <div class="tags">Tags:
                        <?php the_tags(); ?>
                    </div>
                </footer>
            </article>
        <?php endwhile; ?>
    <?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Désolé pour les longs morceaux de code.

Je ne sais pas exactement où réside le problème et je vous serais reconnaissant de toute aide que vous pourriez fournir.

Merci beaucoup, nav

1
navanitachora

Merci pour toute votre aide, en particulier @byronyasgur pour votre dernière suggestion. Cela m'a aidé à le réparer.

J'utilisais markdown comme format de saisie pour le contenu et la première ligne était un commentaire HTML non suivi d'une ligne vierge. L'ajout d'une ligne vide l'a corrigé.

Résumé: L’absence de cette ligne a rendu l’extrait nul. Cette ligne blnak existait dans mon système de développement mais pas dans le système actif.

Les utilisateurs de Markdown se méfient du besoin de lignes vierges.

Désolé pour le bruit.

1
navanitachora