• Resolved Jay

    (@fectio1)


    I have created a custom search form and a custom search page.

    I keep getting a Parse error: syntax error, unexpected $end. I have closed everything that I can see. I am trying to return the results under the search form. Any suggestions. I will be glad to provide the function code it need be.

    Here is the code.

    <div class="search"> <!--Start of main-content -->
    
    <?php get_search_form( $echo ); ?> 
    
    <h2>Search Results</h2>
    <?php
    
    if ( ($_GET['first_name'] == '') && ($_GET['last_name'] == '') )
    {
    
    } else {
    
        $searched_posts = get_reviews_by_custom_search();
    
        foreach ($searched_posts as $searched_post) {
    
            echo "<h3>" . $searched_post->post_title . "</h3>";
    
            echo $searched_post->post_content;
    
            $tags = wp_get_post_tags($searched_post->ID);
                echo "Tags";
                foreach ($tags as $tag) {
                    echo $tag . ", ";
                }
    
            echo "<a href=\"" . $searched_post->post_name . "\">Read More</a>";
    
    }
    ?>
    
    </div>  <!--End of main-content -->
Viewing 2 replies - 1 through 2 (of 2 total)
  • Add another } at the end (after the last } ).

    The one you think closes the if statement actually closes the foreach loop.

    Thread Starter Jay

    (@fectio1)

    Thanks so much. That did allow the search to render, but now I am getting a 404 page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Field Search form’ is closed to new replies.