• Resolved icopydoc

    (@icopydoc)


    Hello! I need to add the description generated by your plugin to the XML feed. But I don’t understand how to work with the Paper class((

    My code:

    add_filter( 'y4ym_f_simple_tag_value_description', 'y4ym_desc_from_rankmath', 10, 2 );
    function y4ym_desc_from_rankmath($xml, $product_id) {
      $product = wc_get_product($product_id);
    
      $generated_desc = RankMath\Paper\Paper::get()->get_description();
     // !! this line $generated_desc is empty!!! ((
    
      ... another code
    }

    I suspect that somehow it is necessary to pass the product ID to the Paper class… I need to get a description that your plugin generates automatically.

Viewing 1 replies (of 1 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @icopydoc,

    Thank you for contacting support.

    First, you need to make sure that you import the class in the file at the very top with something like this:
    use RankMath\Paper\Paper;
    Then you can use the following to import the description:
    $generated = Paper::get()->get_description();
    Please note that the order in what you call this needs to happen inside the wp_head action or some action that happens after that.

    Don’t hesitate to get in touch if you have any other questions.

Viewing 1 replies (of 1 total)
  • The topic ‘How to get the generated description?’ is closed to new replies.