Yoast SEO is a popular plugin for WordPress that provides a way to manage and optimize your website’s SEO. Yoast Social allows you to add social media profile links to your website, which can be included in the Yoast SEO meta data. To add Yoast Social fields to the front-end WooCommerce Dashboard Edit Account page, you can use the following steps:

  1. First, you’ll need to have the Yoast SEO and Yoast Social plugins installed and activated on your website.
  2. Next, you’ll need to create a custom WooCommerce template for the Edit Account page. You can do this by creating a folder called “woocommerce” in your child theme and within that, create a new file called “myaccount/form-edit-account.php”
  3. In form-edit-account.php, you need to copy the code from the parent theme’s woocommerce/myaccount/form-edit-account.php file and then add the Yoast Social fields. The fields can be added using the following code snippet:
Copy code    <p class="form-row form-row-wide">
        <label for="yoast_wpseo_twitter"><?php _e( 'Twitter', 'woocommerce' ); ?></label>
        <input type="text" class="input-text" name="yoast_wpseo_twitter" id="yoast_wpseo_twitter" value="<?php echo esc_attr( get_user_meta( $user->ID, 'yoast_wpseo_twitter', true ) ); ?>" />
    <p class="form-row form-row-wide">
        <label for="yoast_wpseo_facebook"><?php _e( 'Facebook', 'woocommerce' ); ?></label>
        <input type="text" class="input-text" name="yoast_wpseo_facebook" id="yoast_wpseo_facebook" value="<?php echo esc_attr( get_user_meta( $user->ID, 'yoast_wpseo_facebook', true ) ); ?>" />
  1. You also need to add the following code snippet to save the Yoast Social fields in the user’s meta data when the form is submitted:
Copy code    update_user_meta( $user_id, 'yoast_wpseo_twitter', $_POST['yoast_wpseo_twitter'] );
    update_user_meta( $user_id, 'yoast_wpseo_facebook', $_POST['yoast_wpseo_facebook'] );
  1. Finally, you can customize the CSS to match your theme’s style and Add the fields in the template wherever you want to show them.

Please keep in mind that this solution requires some knowledge of PHP, WordPress, and WooCommerce development. Also, be aware that modifying the core files of the plugin or theme may cause issues when you update them, so it’s always recommended to use a child theme or custom plugin to add customizations.

(Visited 14 times, 1 visits today)
Was this article helpful?
Close Search Window