• Resolved aquamarkt

    (@aquamarkt)


    Hello,

    thank for great plugin. I try to add new field in SEO rules (extra SEO description – I need description on the top of the archive during filtering and on the bottom of the archive) using ACF. On backed it is visible on SEO rules but I am not able to add it using any hook. Could you give me any tip how get to the object related with Seo rules?

    add_action( 'woocommerce_after_main_content', 'custom_bottom_seo_description_on_filter', 10 );
    function custom_bottom_seo_description_on_filter() {

    if (class_exists("FilterEverything\Filter\Container")) {
    // Get the SEO description
    $seoFrontEnd = FilterEverything\Filter\Container::instance()->getSeoFrontendService();
    $description = $seoFrontend->get( 'seo_description_bottom' ); // new field added using ACF in Seo rules post
    echo $description
    }
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter aquamarkt

    (@aquamarkt)

    Plugin Support fesupportteam

    (@fesupportteam)

    Hi @aquamarkt

    In theory, you can apply a custom field to the SEO Rules. The main goal here is that you need to display the data from a custom field based on the?SEO Rule?ID.

    if( class_exists( 'FilterEverything\Filter\Pro\PluginPro' ) ){
    $seoFrontend = \FilterEverything\Filter\Container::instance()->getSeoFrontendService();
    $seoRulePostId = $seoFrontend->get( 'seoRulePostId' );

    var_dump($seoRulePostId);
    }

    Basically, you can pull the data from the custom field applied on the exact SEO Rule?ID. But you would need to create custom code for that.

    Best Regards – Victor

    Thread Starter aquamarkt

    (@aquamarkt)

    Thank you very much for help! I put here working code if someone would like to use ACF in Seo rules. If seo rules’s post exist ($seoRulePostId = $seoFrontend->get( ‘seoRulePostId’ );), it can be treat as “I use filter” or should I use dedicated function to check that filter has been used -flrt_is_filter_request?

    add_action( 'woocommerce_after_main_content', 'custom_bottom_seo_description_on_filter', 10 );
    function custom_bottom_seo_description_on_filter()
    {

    if (class_exists("FilterEverything\Filter\Container"))
    {
    $seoFrontend = \FilterEverything\Filter\Container::instance()->getSeoFrontendService();
    $seoRulePostId = $seoFrontend->get( 'seoRulePostId' );
    if (class_exists('ACF'))
    {
    if (!empty($seoRulePostId) && is_numeric($seoRulePostId)) {
    $post = get_post((int) $seoRulePostId); // Cast it to an integer
    if (!empty($post))
    {
    $seo_description_bottom = get_field('seo_description_bottom', $seoRulePostId);
    ?>
    <div class="wd-shop-desc">
    <div class="inside-article">
    <div class="description"><?php echo $seo_description_bottom; ?></div>
    </div>
    </div>
    <?php
    }
    }
    }
    }
    }
    Plugin Support fesupportteam

    (@fesupportteam)

    @aquamarkt

    It is strictly based on your approach. If you need an additional check, you can use flrt_is_filter_request.

    Best Regards – Victor

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.