Thursday, February 12, 2026 | Good afternoon!

FlyingWPress

Switching Bricks Single Templates by Publish Date

Switching Bricks Single Templates by Publish Date

September 17, 2025

This guide (generated by ChatGPT) explains how to automatically switch between two Bricks Builder Single Post templates depending on a post’s publish date.

For example:

  • Posts before September 16, 2025 → Template A
  • Posts on/after September 16, 2025 → Template B

Prerequisites

  • Bricks Builder is installed and active
  • Two Single templates created in Bricks:
    • Template 1 (for older posts)
    • Template 2 (for newer posts)
  • Access to your theme’s functions.php file or an MU-plugin

Grabbing the Template IDs

The easiest way to get the template ID is to look in the shortcodes field within Bricks > Templates.

Screenshot showing the two IDs

Code Snippet

Add the following code to your theme’s functions.php file, wpCodeBox, or to a custom plugin:

<?php
/**
 * Switch Bricks Single templates based on publish date.
 *
 * Template IDs:
 *   - 142628 → Newer posts (on/after cutoff date)
 *   - 143702 → Older posts (before cutoff date)
 *
 * Cutoff date: September 16, 2025
 */

add_filter('bricks/active_templates', 'fw_switch_template_by_publish_date', 10, 3);
function fw_switch_template_by_publish_date($active_templates, $post_id, $content_type) {
  // Only affect single content templates
  if ($content_type !== 'content') {
    return $active_templates;
  }

  // Limit to standard posts only
  if (get_post_type($post_id) !== 'post') {
    return $active_templates;
  }

  // Template IDs
  $TEMPLATE_AFTER  = 142628; // for posts ON/AFTER the cutoff
  $TEMPLATE_BEFORE = 143702; // for posts BEFORE the cutoff

  // Cutoff date (YYYY-MM-DD format)
  $cutoff_ts = strtotime('2025-09-16 00:00:00 UTC');

  // Get publish date (UTC timestamp)
  $published_ts = get_post_time('U', true, $post_id);

  // Decide which template to use
  $active_templates['content'] = ($published_ts >= $cutoff_ts)
    ? $TEMPLATE_AFTER
    : $TEMPLATE_BEFORE;

  return $active_templates;
}

Leave a Reply

Featured