Thursday, February 12, 2026 | Good afternoon!

FlyingWPress

Post Date +

Post Date +

July 14, 2025

I recently needed the ability to automatically show a date based on the date an article was posted, plus a given number of days. I opted to go with the dynamic data approach, and after teaching ChatGPT how to read the Bricks documentation, it was able to write the necessary code (I was multitasking).

Here is how it looks in the Bricks dynamic data selector (Advanced Themer version).

Screenshot of the dynamic data chooser in Bricks.

Just select the dynamic data tag and add the number of days you want calculated — {plus_date:7} for seven days from the post date.

The Code

I added this to wpCodeBox, but it’s easy enough to turn into a plugin.

<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

add_filter( 'bricks/dynamic_tags_list', 'vac_register_plus_date_tag' );
function vac_register_plus_date_tag( $tags ) {
	$tags[] = [
		'name'  => '{plus_date}',
		'label' => esc_html__( 'Post Date + N Days', 'bricks' ),
		'group' => esc_html__( 'post', 'bricks' ),
	];
	return $tags;
}

add_filter( 'bricks/dynamic_data/render_tag', 'vac_render_plus_date_tag', 20, 3 );
function vac_render_plus_date_tag( $tag, $post = null, $context = 'text' ) {
	if ( ! is_string( $tag ) ) {
		return $tag;
	}

	$clean_tag = str_replace( [ '{', '}' ], '', $tag );

	if ( strpos( $clean_tag, 'plus_date:' ) !== 0 ) {
		return $tag;
	}

	$days_raw = str_replace( 'plus_date:', '', $clean_tag );
	$days = max( -3650, min( 3650, intval( $days_raw ) ) ); // limit to ±10 years

	$post_id = ( is_object( $post ) && isset( $post->ID ) ) ? $post->ID : get_the_ID();
	$post_date = get_the_date( 'Y-m-d', $post_id );

	if ( ! $post_date ) {
		return '';
	}

	$timestamp = strtotime( "+$days days", strtotime( $post_date ) );
	return esc_html( date( 'F j, Y', $timestamp ) );
}

add_filter( 'bricks/dynamic_data/render_content', 'vac_replace_plus_date_tag_in_content', 20, 3 );
add_filter( 'bricks/frontend/render_data', 'vac_replace_plus_date_tag_in_content', 20, 2 );
function vac_replace_plus_date_tag_in_content( $content, $post = null, $context = 'text' ) {
	if ( strpos( $content, '{plus_date:' ) === false ) {
		return $content;
	}

	preg_match_all( '/\{plus_date:(\-?\d+)\}/', $content, $matches );

	if ( ! empty( $matches[0] ) ) {
		foreach ( $matches[0] as $i => $full_tag ) {
			$days = max( -3650, min( 3650, intval( $matches[1][$i] ) ) );

			$post_id = ( is_object( $post ) && isset( $post->ID ) ) ? $post->ID : get_the_ID();
			$post_date = get_the_date( 'Y-m-d', $post_id );

			if ( $post_date ) {
				$timestamp = strtotime( "+$days days", strtotime( $post_date ) );
				$replacement = esc_html( date( 'F j, Y', $timestamp ) );
				$content = str_replace( $full_tag, $replacement, $content );
			}
		}
	}

	return $content;
}

Leave a Reply

Featured