Documentation / SEO Rules troubleshooting

SEO Rules troubleshooting

SEO descriptions doesn’t appear.
But H1, title, meta description works

By default SEO rule’s description is attached to the woocommerce_after_shop_loop hook on WooCommerce pages and to the get_the_archive_description hook on the WordPress archive pages. But some WordPress themes use individual hooks in their template files and often replace default WordPress and WooCommerce hooks. This could be the reason, why you may see on filtering pages SEO rule’s title, meta description and H1 title, but don’t see rule’s SEO description. In this case you can add the SEO description to the appropriate hook that present in your theme manually.

Example 1

For example your theme’s archive template file contains hook called 'theme_before_posts'.
It means in the archive.php file you can see next code:

do_action( 'theme_before_posts' );

You can attach SEO description to this hook and it will become visilbe right in the place, where the hook is fired.
Next code you can put into functions.php file of your child theme or in code snippet plugin.

add_action('wp', 'wpc_add_filters_seo_description');
function wpc_add_filters_seo_description(){
    if( class_exists( 'FilterEverything\Filter\Container' ) ){
        $seoFrontEnd = FilterEverything\Filter\Container::instance()->getSeoFrontendService();
        // Replace this with your hook name 
        $your_action_hook_name = 'theme_before_posts';
        add_action( $your_action_hook_name, [ $seoFrontEnd, 'showSeoDescription' ] );
    }
}

Example 2

If your theme’s archive file doesn’t contain any hooks, you can put next code that shows SEO description directly in the place, where you want to display it.

if( function_exists('flrt_get_seo_data') ){
    $seoText = flrt_get_seo_data('text');
    if( $seoText ){
        $seoText = apply_filters( 'the_content', wp_kses_post($seoText) );
        echo sprintf( '<div class="wpc-page-seo-description">%s</div>', $seoText )."\r\n";

    }
}

Make your filtering best with