Time-based meta title/description rotation fields. PRO feature.
| Meta Key | Type | Description |
|---|---|---|
_seoforge_ab_enabled | bool | Whether an A/B test is currently active on this post. |
_seoforge_ab_title_b | string | Variant B title text. Variant A is the regular _seoforge_meta_title or template. |
_seoforge_ab_desc_b | string | Variant B meta description text. |
_seoforge_ab_start | int (timestamp) | Unix timestamp when the test started. Used to calculate weekly variant rotation. |
_seoforge_ab_current | string ('a' or 'b') | The currently active variant (recalculated on each page load). |
_seoforge_ab_served_a | int | Number of impressions (page loads) served for variant A. |
_seoforge_ab_served_b | int | Number of impressions (page loads) served for variant B. |
php
// ----- Starting an A/B test programmatically -----
$post_id = 42;
update_post_meta( $post_id, '_seoforge_ab_enabled', true );
update_post_meta( $post_id, '_seoforge_ab_title_b', 'Alternative SEO Title for A/B Testing' );
update_post_meta( $post_id, '_seoforge_ab_desc_b', 'This is the alternative description being tested.' );
update_post_meta( $post_id, '_seoforge_ab_start', time() );
update_post_meta( $post_id, '_seoforge_ab_served_a', 0 );
update_post_meta( $post_id, '_seoforge_ab_served_b', 0 );php
// ----- Reading A/B test status -----
$post_id = 42;
$enabled = get_post_meta( $post_id, '_seoforge_ab_enabled', true );
$variant = get_post_meta( $post_id, '_seoforge_ab_current', true );
$start = (int) get_post_meta( $post_id, '_seoforge_ab_start', true );
$weeks = floor( ( time() - $start ) / WEEK_IN_SECONDS );
$served_a = (int) get_post_meta( $post_id, '_seoforge_ab_served_a', true );
$served_b = (int) get_post_meta( $post_id, '_seoforge_ab_served_b', true );
// Calculate which variant should be active right now
$calculated_variant = ( $weeks % 2 === 0 ) ? 'a' : 'b';
// Stop A/B test and keep the winner
update_post_meta( $post_id, '_seoforge_ab_enabled', false );—