How to get Description Meta of Product Category

#437848
  • Resolved Laptop Titan
    Rank Math free

    I want to get the description of Rank Math in the product catalog. How to do that.

    This code I will edit in the function file of the child theme

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math support today and bringing your concern to our attention.

    You may refer to this filter code on how you would access the incoming meta description to all types of pages:

    add_filter( 'rank_math/frontend/description', function( $description ) {
    	return $description;
    });

    If you wish to directly tap into the meta, you may use the code below:

    RankMath\Post::get_meta( 'description', YOUR_ID_HERE )

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Appreciate your help.

    I will research on it and will report the results here

    Hello,

    Glad that helped.

    Sure, let us know how this goes.

    Meanwhile, please don’t hesitate to contact us anytime if you have other questions to assist you further.

    Looking forward to helping you.

    Thank you.

    Sorry I’m not good at coding

    How to use

    RankMath\Post::get_meta( 'description', YOUR_ID_HERE )

    when I already have the ID of the Product Category

    I use

    echo RankMath\Post::get_meta( 'description', MY ID)

    But it doesn’t work

    Hello,

    When you already have the ID, you can simply pass the value instead of the “MY ID” value you have there.

    You can also pass a variable with the ID, in case that’s how you are getting it.

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

    LOL, I know the basics.

    I have manually entered the category product id but it is not working.

    This is how i get the product category id while visiting that product category page.

    // Get Current Category ID WooCommerce
     
    add_action('wp_head', 'get_current_category_id');
     
    function get_current_category_id(){
     
    $current_category_object = get_queried_object();
     
    echo $current_category_object ->term_id;
     
    }

    Hello,

    Please try this instead:

    
    $current_category_object = get_queried_object();
    get_term_meta($current_category_object->term_id, 'rank_math_description', true);
    

    Let us know how that goes. Looking forward to helping you.

    Perfect, it works fine

    Thanks for the support of the Rank Math team!

    My final code

    $current_category_object = get_queried_object();
    echo get_term_meta($current_category_object->term_id, 'rank_math_description', true);

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘How to get Description Meta of Product Category’ is closed to new replies.