1. Home
  2. Docs
  3. Developer Guide
  4. Miscellaneous and Snippet...
  5. Changing the number of properties shown per page

Changing the number of properties shown per page

When deciding how many properties to show on each property search results page Property Hive will use the ‘Blog pages show at most’ value set in WordPress under ‘Settings > Reading’.

One way to amend the number of properties shown is to amend this setting. However, if you have a blog page, or display posts elsewhere on your website, changing this value may impact other areas of the site.

The other way to change this is to add the following to your theme’s functions.php file:

add_filter( 'loop_search_results_per_page', 'change_properties_per_page', 20 );
function change_properties_per_page()
{
    return 30; // 30 per page. Change this to match your needs
}

 

A Note Regarding Divi

Divi seems to have it's own method of determining the posts shown per page on archive pages. As a result you will need to use this instead:

function custom_posts_per_page( $query ) {
    if ( !is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'property' ) ) {
        $query->set('posts_per_page', 30 ); // Change 30 to be your desired amount
    }
}
add_action( 'pre_get_posts', 'custom_posts_per_page', 99 );
Was this article helpful to you? No Yes

How can we help?