WP Residence Help WP Residence Help

  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required, WpResidence 5.0 / WPResidence Blog List Template Guide

WPResidence Blog List Template Guide

143 views 0

Comprehensive Guide to WPResidence Blog List Template

Introduction

This guide provides an in-depth explanation of the blog_list.php template file in the WPResidence theme. We’ll explore its structure, functionality, and how to extend or customize various components.

Template Location and Purpose

The blog_list.php file is located in the page-templates\blog_list.php Its primary purpose is to display a list of blog posts in a customizable layout. This template is used when a page is assigned the “Blog list page” template in the WordPress admin.

Template Structure and Functionality

1. Header and Initial Setup

The template starts by including the header and setting up necessary variables:


<?php
get_header();
$wpestate_options = get_query_var('wpestate_options', array());
$blog_unit = wpestate_blog_unit_selector();
$blog_unit_class_request = wpestate_blog_unit_column_selector($wpestate_options);
$blog_unit_class = $blog_unit_class_request['col_class'];
?>

The wpestate_blog_unit_selector() function, found in libs/blog_post/blog_post_functions.php, determines which blog unit template to use. You can customize this selection by using the wpestate_blog_unit_type filter in your child theme’s functions.php:


add_filter('wpestate_blog_unit_type', 'custom_blog_unit_type');
function custom_blog_unit_type($type) {
return 'blog_unit2.php'; // Change to your desired blog unit template
}

The wpestate_blog_unit_column_selector() function, also in libs/blog_post/blog_post_functions.php, determines the column class for blog units. To modify this, you’d need to override the function in your child theme.

2. Main Content Structure

The template creates a container for the blog list and includes breadcrumbs:


<div class="row wpresidence_page_content_wrapper">
<?php get_template_part('templates/breadcrumbs'); ?>
<div class="<?php echo esc_attr(isset($wpestate_options['content_class']) ? $wpestate_options['content_class'] : ''); ?>">
<?php get_template_part('templates/ajax_container'); ?>

The breadcrumbs.php file (in the templates folder) generates the breadcrumb navigation, while ajax_container.php sets up a container for potential AJAX-loaded content.

3. Page Content

If the page has content, it’s displayed before the blog list:


<?php while (have_posts()) : the_post(); ?>
<?php if (esc_html(get_post_meta($post->ID, 'page_show_title', true)) == 'yes') { ?>
<h1 class="entry-title title_prop"><?php the_title(); ?></h1>
<?php } ?>
<div class="single-content"><?php the_content(); ?></div>
<?php endwhile; ?>

To add custom content before the blog list, you can use the wpestate_before_blog_list action hook:


add_action('wpestate_before_blog_list', 'custom_before_blog_list');
function custom_before_blog_list() {
echo '<div class="custom-blog-intro">Welcome to our blog!</div>';
}

4. Blog Posts Query and Display

The template queries and displays blog posts:


<div class="blog_list_wrapper container">
<div class="row">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 0;
$args = array(
'post_type' => 'post',
'paged' => $paged,
'status' => 'published'
);
$blog_selection = new WP_Query($args);
while ($blog_selection->have_posts()): $blog_selection->the_post();
include(locate_template($blog_unit));
endwhile;
wp_reset_query();
?>
</div>
</div>

To modify the query, use the pre_get_posts action in your child theme’s functions.php:


add_action('pre_get_posts', 'custom_blog_query');
function custom_blog_query($query) {
if (!is_admin() && $query->is_main_query() && is_page_template('blog_list.php')) {
$query->set('posts_per_page', 5);
$query->set('orderby', 'title');
$query->set('order', 'ASC');
}
}

5. Pagination

Pagination is handled by the wpestate_pagination() function, found in libs/pagination.php:


<?php wpestate_pagination($blog_selection->max_num_pages, 2); ?>

6. Sidebar and Footer

The template includes a sidebar and the footer:


<?php include get_theme_file_path('sidebar.php'); ?>
</div>
<?php get_footer(); ?>

CSS Customization

The main CSS classes for the blog list template can be found in these SCSS files within the scss\pages\_blog.scss or scss\blog_card\_blog_card_v1.scss folders of the WPResidence theme:

  • _blog_card.scss: Styles for the basic blog card layout
  • _blog_card_v2.scss: Styles for version 2 of the blog card
  • _blog_card_v3.scss: Styles for version 3 of the blog card
  • _blog_card_v4.scss: Styles for version 4 of the blog card
  • _blog_card_related.scss: Styles for related blog posts

To customize these styles, add your CSS to your child theme’s style.css file. For example:


.blog_list_wrapper {
margin-top: 30px;
}
.blog_unit {
border: 1px solid #eee;
padding: 15px;
}
.pagination {
margin-top: 20px;
}

Technical how to | Custom Code RequiredWpResidence 5.0

Related Articles

  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display
  • Configuring the Primary Navigation Menu in WPResidence

WP Residence Documentation

  • 1. General
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 2. Installation
  • 3. Installation FAQ
  • 4. Advanced Search
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 5. Agent, Agency & Developers
  • 6. Property Page
  • 7. Properties List
  • 8. Property Taxonomies
  • 9. Property Custom Template
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • Theme Options
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • Translation
  • FAQ
  • Pages
  • Header
  • Footer
  • Google or Open Street Maps
  • Payment Options
  • Plugins
    • Included Plugins
    • Third Party Plugins – IDX Compatibility
    • Third Party Plugins – Multi Languages
    • Third party Plugins – Other
  • Technical
    • Technical how to | Custom Code Required
    • Technical: Child Theme
  • Theme Updates

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API