25. Content Decay API | SEO Forge - Rank Higher with AI-Powered SEO
Download Log in

25. Content Decay API

Developer Guide

Work with content decay data to identify and refresh underperforming content.

Reading Cached Decay Data

php
// The daily cron populates this cache
$decay = get_option( 'seoforge_gsc_decay_cache', [] );

foreach ( $decay as $item ) {
    printf(
        "Post #%d (%s): clicks %d -> %d (%.0f%%), position %.1f -> %.1fn",
        $item['post_id'],
        $item['title'],
        $item['clicks_prev'],
        $item['clicks_now'],
        $item['click_change'],
        $item['position_prev'],
        $item['position_now']
    );
}

Auto-Refreshing Decaying Content

php
// Detect decaying content and trigger re-optimization
add_action( 'seoforge_daily_gsc_sync', function () {
    if ( ! class_exists( 'SEOFORGE_GSC' ) || ! SEOFORGE_GSC::instance()->is_connected() ) {
        return;
    }

    $decay = SEOFORGE_GSC::instance()->detect_content_decay();

    foreach ( $decay as $item ) {
        if ( $item['click_change'] < -50 && $item['post_id'] ) {
            // Flag for editorial review via custom meta
            update_post_meta( $item['post_id'], '_needs_content_refresh', '1' );
            update_post_meta( $item['post_id'], '_decay_detected_at', current_time( 'mysql' ) );
        }
    }
}, 20 );

Building a Decay Dashboard

php
// WP-Admin page listing all decaying posts
$flagged = get_posts( [
    'post_type'      => 'any',
    'posts_per_page' => -1,
    'meta_key'       => '_needs_content_refresh',
    'meta_value'     => '1',
] );

foreach ( $flagged as $post ) {
    $detected = get_post_meta( $post->ID, '_decay_detected_at', true );
    echo esc_html( $post->post_title ) . " (flagged: {$detected})n";
}

Forge AI Assistant Online

Hi! I'm the SEO Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs