Custom add text to Title Yoast SEO, Taxonomy Product Woocommerce Wordpress

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

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,032
    Đã được thích:
    81
    Điểm thành tích:
    48
    hi mọi người như tiêu đề câu hỏi: Custom add text to Title Yoast SEO, Taxonomy Product Woocommerce Wordpress
    Mình đang muốn add thêm số lượng sản phẩm sau mõi phân loại Taxonomy của sản phẩm trong Woocommerce.
    Và muốn add thêm số lượng tổng sản phẩm vào sau mỗi chuyên mục sản phẩm của tiêu đề SEO.

    VD về chuyên mục sản phẩm
    • Tiêu đề mặc định cũ: bóng đèn dây tóc thế hệ mới 2024
    • Tiêu đề muốn đổi lại: bóng đèn dây tóc thế hệ mới 2024 có 120 sản phẩm
    VD về taxonomy có type là: pa_thuong-hieu
    • Tiêu đề mặc định cũ: thương hiệu Liz
    • Tiêu đề muốn đổi lại: thương hiệu Liz hiện có 22 sản phẩm
     
    Cảm ơn đã xem bài:

    Custom add text to Title Yoast SEO, Taxonomy Product Woocommerce Wordpress

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,931
    Đã được thích:
    1,203
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Em add code sau vào function.php của themes nhé
    Mã:
    add_filter('wpseo_title', 'filter_product_wpseo_title');
    function filter_product_wpseo_title($title) {
        if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
          $term = get_queried_object();
          if($term->taxonomy == "pa_thuong-hieu")
          {
            if(empty($a))
            {
              $title = 'Thương hiệu '.$term->name.', '.$term->count.' sản phẩm - Thương hiệu website';
            }else{
              $title = $title.', '.$term->count.' sản phẩm - Thương hiệu website';
            }
          }elseif(is_product_category())
          {
            $title = $title.', '.$term->count.' sản phẩm';
          }
          else{
            $title = $title.' - Thương hiệu website';
          }
        }
        return $title;
    }
    
     


Chủ để tương tự : Custom text
Diễn đàn Tiêu đề Date
Mã nguồn mở Wordpress Get values from user Advanced Custom Fields (ACF) wordpress? 30/11/21
Mã nguồn mở Wordpress Get all Products by Custom Field ACF Id and Value in Woocommerce ? 28/10/21
Mã nguồn mở Wordpress Add text, Replace vào sau mỗi tiêu (title) đề sản phẩm SEO Yoast Wordpress 18/8/23
Mã nguồn mở Wordpress Thêm text giá trước giá sản phẩm woocommerce wordpress 31/7/23
Mã nguồn mở Wordpress Translate strings text in file function.php using Plugin Polylang ? 28/10/22