Remove Json/LD Structured Data Format Markup WooCommerce và Yoast Seo

Thảo luận trong 'Mã nguồn mở Wordpress' bắt đầu bởi seolagi, 28/5/19.

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,027
    Đã được thích:
    80
    Điểm thành tích:
    48
    Cho mình hỏi cách xóa dữ liệu có cấu trúc mặc định của wordpress được thêm bởi themes code của WooCommerce và Yoast SEO plugin như thế nào vậy? mình muốn xóa toàn bộ các thẻ dữ liệu có cấu trúc đi thì làm sao khi muốn xóa nó bằng code trọng functions.php của themes?
    Xóa các js code sau: và nhiều cái khác nữa
    Mã:
    https://schema.org/Product
    https://schema.org/WebPage
    WooCommerce to Remove schema.org Markup from Product Categories, Remove the WooCommerce JSON/LD Structured Data Format
     
    Cảm ơn đã xem bài:

    Remove Json/LD Structured Data Format Markup WooCommerce và Yoast Seo

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,883
    Đã được thích:
    1,193
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Để xóa tất cả các thẻ cấu trúc dữ liệu của SEO Yoast bạn thêm code sau vào Functions.php
    Mã:
    function disable_yoast_schema_data($data){
        $data = array();
        return $data;
    }
    add_filter('wpseo_json_ld_output', 'disable_yoast_schema_data', 10, 1);
    Để xóa tất cả các thẻ cấu trúc dữ liệu của WooCommerce bạn thêm code sau vào Functions.php
    Mã:
    function remove_output_structured_data() {
      remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 ); // This removes structured data from all frontend pages
      remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 ); // This removes structured data from all Emails sent by WooCommerce
    }
    add_action( 'init', 'remove_output_structured_data' );
     
  3. ungduong
    Tham gia ngày:
    22/7/19
    Bài viết:
    1
    Đã được thích:
    0
    Điểm thành tích:
    1
    Giới tính:
    Nam
    Code trên không áp dụng được cho bản WooCommerce bản 3.6.5 mới nhất bác à. Bản trước đó em add code này thì ok. Bác xem có cao kiến gì không?