Use a custom template file for property and search result pages

This solution is for “classic” theme’s with PHP templates. Block Theme support coming soon.

In many cases it can be useful to use a custom template file for SimplyRETS pages, like single property pages and search results. For example, if you want to add any custom features, use a unique header and footer, or add/remove a sidebar – a custom template file is how you would do it!

By default, the SimplyRETS plugin will use the page.php template from your theme*. To use a custom template, simply add a file named single-sr-listings.php to your theme or child theme!

An easy way to get started is to simply _copy_ your theme’s existing page.php file to a new file named single-sr-listings.php. Then you can go in and make any desired updates without having to rewrite the entire template from scratch.

Here is a simple example of a custom template file:

<?php
/**
 * The template for displaying SimplyRETS pages.
 */
 
get_header(); ?>
 
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
 
        <?php
        // Start the loop.
        while ( have_posts() ) : the_post();

        the_content();
 
        // End the loop.
        endwhile;
        ?>
 
        </main><!-- .site-main -->
    </div><!-- .content-area -->
 
<?php get_footer(); ?>

That’s basically it! The only important part for the SimplyRETS plugin is the function the_content(). This is where SimplyRETS adds the HTML to the page for search results and property pages.

Outside of that one function, you can customize the entire template however you need.

Leave a Reply

Close Menu