0

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 !

3
  • 2
    What is in assets/php/posts.php? From the name (plural) it sounds like it's something that does it's own loop. That could be confusing things.
    – BinaryMoon
    Commented Jan 9, 2022 at 20:29
  • is this the entire template? What does the rest of the file look like?
    – Tom J Nowell
    Commented Jan 9, 2022 at 21:04
  • My file "post.php" is the content that will be displayed in a loop.
    – Maximus
    Commented Jan 17, 2022 at 18:46

0

Your Answer

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

Browse other questions tagged or ask your own question.