php – WP Search page didn’t to loop my posts

Question

I want to display the publications searched for via “searchform.php” in the “search.php” page but it does not work …

The search is done well when I look at the url (ex: New World):
http://localhost/?post_type=post&s=New+World

But I have nothing displayed on the results page, I fall directly into the “else”.

Here is my code:

                    <?php if (have_posts()) : ?>
                        <?php while (have_posts()) : the_post(); ?>
                            <?php get_template_part('content', 'search'); ?>
                            <?php include("assets/php/posts.php"); ?>
                        <?php endwhile; ?>
                    <?php else : ?>
                      ...
                    <?php endif; ?>

Thank you in advance for your help !

0
Maximus 7 months 2022-01-09T14:46:45-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse