Halloween Sale 15% off Ends in See the plans
PHP

Block Pattern: Company History Timeline

Adds a timeline pattern with a year column and a description column for each milestone, for About and history pages.

Don’t have WPIDE yet? Install it on your site

Code

add_action( 'init', function () {
    if ( ! function_exists( 'register_block_pattern' ) ) {
        return;
    }

    if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'wpide-sections' ) ) {
        register_block_pattern_category( 'wpide-sections', array( 'label' => 'Site Sections' ) );
    }

    $milestones = array(
        '2014' => 'Founded in a small garage with two people and one big idea.',
        '2018' => 'Opened our first office and welcomed our 1,000th customer.',
        '2023' => 'Launched internationally and grew the team to 40 people.',
    );

    $rows = '';
    foreach ( $milestones as $year => $text ) {
        $rows .= '<!-- wp:columns --><div class="wp-block-columns"><!-- wp:column {"width":"25%"} --><div class="wp-block-column" style="flex-basis:25%"><!-- wp:heading {"level":3} --><h3 class="wp-block-heading">' . esc_html( $year ) . '</h3><!-- /wp:heading --></div><!-- /wp:column --><!-- wp:column {"width":"75%"} --><div class="wp-block-column" style="flex-basis:75%"><!-- wp:paragraph --><p>' . esc_html( $text ) . '</p><!-- /wp:paragraph --></div><!-- /wp:column --></div><!-- /wp:columns -->';
    }

    register_block_pattern( 'wpide/history-timeline', array(
        'title'       => 'Timeline: company history',
        'description' => 'Milestones with a year and a description.',
        'categories'  => array( 'wpide-sections', 'about' ),
        'keywords'    => array( 'timeline', 'history', 'milestones' ),
        'content'     => '<!-- wp:group {"layout":{"type":"constrained"}} --><div class="wp-block-group"><!-- wp:heading --><h2 class="wp-block-heading">Our journey</h2><!-- /wp:heading -->' . $rows . '</div><!-- /wp:group -->',
    ) );
} );

Notes

Duplicate a row (Columns block) to add more milestones.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.