Adding Custom Field to Meta Description of WC Archive Page doesn’t work

#49961
  • Resolved Kai Dickas
    Rank Math free

    Hi,

    i’m using toolset plugins to add custom fields to WooCommerce Categories.
    With Toolset i’ve added a field called “wpcf-kategorie-beschreibung” to all woocommerce categories. If i edit a categorie the custom field shows up. So far so good. But if i try to use the value of the custom field for the meta description and i’m using your code %customfield(wpfc-kategorie_beschreibung)% for it. Nothing happens. I’ve tried to use the code (with a product related custom field of course) on a single product page and it works fine.

    I’m no coder but i’ve already tried to use the code for the functions.php you’ve mentioned here: https://support.rankmath.com/ticket/advanced-custom-fields-not-load-the-field/

    Nothing changed.

    Please help me with a solution.

    • This topic was modified 3 years, 11 months ago by Kai Dickas.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Alberto
    Rank Math business

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for contacting Rank Math today.

    I’ve added the following code on your theme to get the description from the “kategorie-beschreibung” on the product category pages:

    /**
     * Allow changing the meta description sentence from within the theme.
     *
     * @param string $description The description sentence.
     */
    add_filter( 'rank_math/frontend/description', function( $description ) {
          if(is_product_category() && types_render_termmeta('kategorie-beschreibung') ){
             $description = types_render_termmeta('kategorie-beschreibung');
             return $description;
    	  }
    	return $description;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hi,

    thanks for your reply.
    If i get it right now for every categorie archive page it uses the “kategorie-beschreibung” field. But i only wanna use this for a selected number of categories. For some categories i’ve added an individual meta description.

    How am i able to do so?

    HI Kai,

    Thanks for the follow up.

    You can extend the code to include an array of category slugs that you would like this to apply to like so:

    /**
     * Allow changing the meta description sentence from within the theme.
     *
     * @param string $description The description sentence.
     */
    add_filter( 'rank_math/frontend/description', function( $description ) {
          $categories = array('shirts','socks');
          if(is_product_category($categories) && types_render_termmeta('kategorie-beschreibung') ){
             $description = types_render_termmeta('kategorie-beschreibung');
             return $description;
    	  }
    	return $description;
    });

    We are looking forward to helping you. Thank you.

    That worked well. Thanks.

    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.

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

The ticket ‘Adding Custom Field to Meta Description of WC Archive Page doesn’t work’ is closed to new replies.