// Add custom Theme Functions here // function devvn_remove_slug( $post_link, $post ) { if ( !in_array( get_post_type($post), array( 'product' ) ) || 'publish' != $post->post_status ) { return $post_link; } if('product' == $post->post_type){ $post_link = str_replace( '/san-pham/', '/', $post_link ); //Thay cua-hang bằng slug hiện tại của bạn }else{ $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); } return $post_link; } add_filter( 'post_type_link', 'devvn_remove_slug', 10, 2 ); /*Sửa lỗi 404 sau khi đã remove slug product hoặc cua-hang*/ function devvn_woo_product_rewrite_rules($flash = false) { global $wp_post_types, $wpdb; $siteLink = esc_url(home_url('/')); foreach ($wp_post_types as $type=>$custom_post) { if($type == 'product'){ if ($custom_post->_builtin == false) { $querystr = "SELECT {$wpdb->posts}.post_name, {$wpdb->posts}.ID FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_status = 'publish' AND {$wpdb->posts}.post_type = '{$type}'"; $posts = $wpdb->get_results($querystr, OBJECT); foreach ($posts as $post) { $current_slug = get_permalink($post->ID); $base_product = str_replace($siteLink,'',$current_slug); add_rewrite_rule($base_product.'?$', "index.php?{$custom_post->query_var}={$post->post_name}", 'top'); add_rewrite_rule($base_product.'comment-page-([0-9]{1,})/?$', 'index.php?'.$custom_post->query_var.'='.$post->post_name.'&cpage=$matches[1]', 'top'); add_rewrite_rule($base_product.'(?:feed/)?(feed|rdf|rss|rss2|atom)/?$', 'index.php?'.$custom_post->query_var.'='.$post->post_name.'&feed=$matches[1]','top'); } } } } if ($flash == true) flush_rewrite_rules(false); } add_action('init', 'devvn_woo_product_rewrite_rules'); /*Fix lỗi khi tạo sản phẩm mới bị 404*/ function devvn_woo_new_product_post_save($post_id){ global $wp_post_types; $post_type = get_post_type($post_id); foreach ($wp_post_types as $type=>$custom_post) { if ($custom_post->_builtin == false && $type == $post_type) { devvn_woo_product_rewrite_rules(true); } } } add_action('wp_insert_post', 'devvn_woo_new_product_post_save'); function devvn_custom_woocommerce_structured_data_product ($data) { global $product; $data['brand'] = $product->get_attribute('pa_sachifoods') ? $product->get_attribute('pa_sachifoods') : null; $data['mpn'] = $product->get_sku() ? $product->get_sku() : null; $data['id'] = $product->get_id() ? $product->get_id() : null; return $data; } add_filter( 'woocommerce_structured_data_product', 'devvn_custom_woocommerce_structured_data_product' ); /* * Remove product-category in URL * Thay product-category bằng slug hiện tại của bạn. Mặc định là product-category */ add_filter( 'term_link', 'devvn_product_cat_permalink', 10, 3 ); function devvn_product_cat_permalink( $url, $term, $taxonomy ){ switch ($taxonomy): case 'product_cat': $taxonomy_slug = 'danh-muc'; //Thay bằng slug hiện tại của bạn. Mặc định là product-category if(strpos($url, $taxonomy_slug) === FALSE) break; $url = str_replace('/' . $taxonomy_slug, '', $url); break; endswitch; return $url; } // Add our custom product cat rewrite rules function devvn_product_category_rewrite_rules($flash = false) { $terms = get_terms( array( 'taxonomy' => 'product_cat', 'post_type' => 'product', 'hide_empty' => false, )); if($terms && !is_wp_error($terms)){ $siteurl = esc_url(home_url('/')); foreach ($terms as $term){ $term_slug = $term->slug; $baseterm = str_replace($siteurl,'',get_term_link($term->term_id,'product_cat')); add_rewrite_rule($baseterm.'?$','index.php?product_cat='.$term_slug,'top'); add_rewrite_rule($baseterm.'page/([0-9]{1,})/?$', 'index.php?product_cat='.$term_slug.'&paged=$matches[1]','top'); add_rewrite_rule($baseterm.'(?:feed/)?(feed|rdf|rss|rss2|atom)/?$', 'index.php?product_cat='.$term_slug.'&feed=$matches[1]','top'); } } if ($flash == true) flush_rewrite_rules(false); } add_action('init', 'devvn_product_category_rewrite_rules'); /*Sửa lỗi khi tạo mới taxomony bị 404*/ add_action( 'create_term', 'devvn_new_product_cat_edit_success', 10, 2 ); function devvn_new_product_cat_edit_success( $term_id, $taxonomy ) { devvn_product_category_rewrite_rules(true); } add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' ); // < 2.1 add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' ); // 2.1 + function woo_custom_cart_button_text() { return __( 'Xem chi tiết', 'woocommerce' ); }{"id":4241,"date":"2021-11-23T15:04:44","date_gmt":"2021-11-23T08:04:44","guid":{"rendered":"https:\/\/www.banhtrangsachi.com\/?p=4241"},"modified":"2022-09-20T09:05:56","modified_gmt":"2022-09-20T02:05:56","slug":"kho-ca-thieu-dam-da-huong-vi-bien-ca","status":"publish","type":"post","link":"https:\/\/banhtrangsachi.com\/am-thuc\/kho-ca-thieu-dam-da-huong-vi-bien-ca\/","title":{"rendered":"Kh\u00f4 c\u00e1 thi\u1ec1u \u0111\u1eadm \u0111\u00e0 h\u01b0\u01a1ng v\u1ecb bi\u1ec3n c\u1ea3"},"content":{"rendered":"

\"GIAN<\/p>\n

Nh\u1eafc \u0111\u1ebfn \u0111\u1eb7c s\u1ea3n Quy Nh\u01a1n \u2013 kh\u00f4 c\u00e1 thi\u1ec1u t\u1ea9m gia v\u1ecb, du kh\u00e1ch c\u00f3 th\u1ec3 kh\u00f4ng ki\u1ec1m \u0111\u01b0\u1ee3c l\u00f2ng m\u00e0 \u201cmu\u1ed1n mua h\u1ebft\u201d.\u00a0M\u00f3n \u0103n n\u00e0y n\u1ed5i ti\u1ebfng g\u1ea7n xa \u0111\u1eadm h\u01b0\u01a1ng v\u1ecb \u201cbi\u1ec3n c\u1ea3\u201d.<\/strong>
\nKh\u00f4 c\u00e1 thi\u1ec1u \u0111\u01b0\u1ee3c ch\u1ebf bi\u1ebfn v\u1edbi s\u1ee3i m\u00e0u v\u00e0ng, d\u00e0i, t\u1ea9m gia v\u1ecb ch\u00ednh l\u00e0 n\u01b0\u1edbc m\u1eafm nh\u0129 th\u01a1m ngon, nguy\u00ean ch\u1ea5t v\u00e0 ti\u00eau. Khi n\u1ebfm m\u00f3n kh\u00f4 c\u00e1 thi\u1ec1u, b\u1ea1n s\u1ebd c\u1ea3m nh\u1eadn \u0111\u01b0\u1ee3c ch\u00fat m\u1eb7n, ch\u00fat ng\u1ecdt v\u00e0 cay n\u1ed3ng n\u01a1i s\u1ed1ng m\u0169i c\u1ee7a ti\u00eau. Th\u1ebf n\u00ean ch\u1ec9 c\u1ea7n nh\u00ecn th\u1ea5y th\u00f4i l\u00e0 b\u1ea1n c\u0169ng \u0111\u00e3 mu\u1ed1n n\u1ebfm th\u1eed ch\u00fang ngay r\u1ed3i.<\/p>\n

\"Kh\u00f4<\/p>\n

\"Kh\u00f4<\/p>\n

C\u00e1 thi\u1ec1u t\u1ea9m s\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng nhi\u1ec1u trong nh\u1eefng b\u00e0n nh\u1eadu, nh\u1eafm v\u1edbi r\u01b0\u1ee3u, bia, tr\u1edf th\u00e0nh m\u00f3n khai v\u1ecb \u0111\u1eb7c bi\u1ec7t. M\u00f3n \u0111\u1eb7c s\u1ea3n<\/a> n\u00e0y r\u1ea5t th\u00edch h\u1ee3p cho nh\u1eefng chuy\u1ebfn \u0111i d\u00e3 ngo\u1ea1i, mua v\u1ec1 l\u00e0m qu\u00e0 cho nh\u1eefng ng\u01b0\u1eddi th\u00e2n y\u00eau.<\/p>\n

N\u1ebfu b\u1ea1n c\u00f3 c\u01a1 h\u1ed9i gh\u00e9 Quy Nh\u01a1n, tuy\u1ec7t \u0111\u1ed1i \u0111\u1eebng b\u1ecf qu\u00ean m\u00f3n kh\u00f4 c\u00e1 thi\u1ec1u n\u00e0y nh\u00e9!<\/p>\n

H\u00ca\u0323 TH\u00d4\u0301NG BA\u0301N HA\u0300NG ONLIE<\/strong><\/p>\n

\n