Customize the Timeline Layout Template

This documentation explains how to customize the layout of your Post Timeline using a custom class. You can modify the number of slides, appearance, and rendering of posts in Layout 0 to suit your needs.

Customizing Layout with functions.php

To customize your Post Timeline layout, you’ll need to add some code to your theme’s functions.php file.

Include Custom Layout Class: First, include a custom class that will allow you to edit the layout.

include 'post-timeline-layout.php';

Add a Filter for Overrides:

Add a filter to enable theme overrides for the Post Timeline layout. This filter lets you specify a custom class to override the default layout class.

add_filter('ptl_layout_override', function($class_name) {
    // Check if the layout class is for Layout 0.
    if ($class_name == '\PostTimeline\Layouts\Layout_0') {
        return 'PTL_Layout_Edit'; // Return the custom layout class for Layout 0.
    }
    // Return the original class if no override is specified.
    return $class_name;
});

Creating a Custom Layout Class with post-timeline-layout.php

Now, create a custom class to override the behavior of Post Timeline Layout 0. This class allows you to make modifications to the rendering of individual posts in Layout 0.

use PostTimeline\Layouts\Layout_0;

/**
 * Class PTL_Layout_Edit
 *
 * This class is responsible for customizing the behavior of Post Timeline Layout 0 in your theme.
 */
class PTL_Layout_Edit extends Layout_0 {

    /**
     * Render a Post with Custom Modifications:
     *
     * This method lets you customize the rendering of individual posts in Layout 0. You can make changes to the appearance and behavior of posts here.
     *
     * @param object $post The post object to render.
     * @param bool $is_even Indicates whether the post is at an even index.
     */
    public function render_post($post, $is_even) {
        // Add your custom modifications to the rendering of posts here.
    }
}