Đôi khi bạn cần chặn cập nhật WordPress vì lý do gì đó, đây là đoạn code giúp bạn không cho WordPress cập nhật phiên bản mới của WordPress, Giao diện và Plugin /*Chặn update*/ function remove_core_updates(){ global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,); } add_filter('pre_site_transient_update_core','remove_core_updates'); add_filter('pre_site_transient_update_plugins','remove_core_updates'); add_filter('pre_site_transient_update_themes','remove_core_updates'); Bạn chèn vào file functions.php của giao diện đang dùng là được. Nói chung thì mình không khuyến khích chặn cập nhật WordPress đâu, cập nhật lên phiên bản mới nhất sẽ giúp website của bạn an toàn hơn.
Thêm nội dung vào trước và sau giá của sản phẩm trong Woocommerce
Trong bài này chúng ta sẽ thêm nội dung bất kỳ vào trước và sau giá của sản phẩm trong Woocommerce. Trong tiếng anh gọi là Prefix và Suffix 😀 Bạn có nhiều website và nhiều mặt hàng khác nhau. Ví dụ web bán quần áo thì giá sẽ tính theo bộ. Còn web bán mật ong thì giá lại tính theo hộp, lọ; còn web bán bất động sản thì giá sẽ tính theo m2 chẳng hạn 🙂 Vì thế hôm nay chúng ta sẽ thêm ghi chú đó vào giá để khách hàng dễ nhận biết Thêm cài đặt vào Woocommerce. Bước này để thêm 2 ô textbox…
Thêm nút xem thêm và thu gọn cho danh mục, chi tiết sản phẩm WooCommerce trên theme Flatsome
Hướng dẫn thêm nút xem thêm và thu gọn cho danh mục, chi tiết sản phẩm WooCommerce wordpress, với đoạn code này bạn có thể rút gọn nội dung cho sản phẩm, danh mục, bài viết hoặc thậm chí tất cả đoạn nào muốn làm ngắn lại trong wordpress. Hình minh họa sau khi thêm thành công: Code thu gọn nội dung mô tả của danh mục sản phẩm Với đoạn code này bạn có thẻ thu gọn nội dung phần mô tả của danh mục sản phẩm WooCommerce một cách dễ dàng, khi thêm code sẽ xuất hiện nút xem thêm và thu gọn sản phẩm, bạn hoặc khách…
Thiết lập tìm kiếm chính xác trong WordPress
Công cụ tìm kiếm của WordPress hơi cùi bắp, tìm kiếm không chính xác cho lắm, Dưới đây là cách thiết lập để công cụ tìm kiếm của WordPress chính xác hơn. 1 – Tìm kiếm chính xác trong tiêu đề và nội dung Các bạn, hãy mở file functions.php của theme đang sử dụng và thêm vào đó đoạn code sau: add_filter('posts_search', 'pvs_search_is_exact', 20, 2); function pvs_search_is_exact($search, $wp_query){ global $wpdb; if(empty($search)) return $search; $q = $wp_query->query_vars; $n = !empty($q['exact']) ? '' : '%'; $search = $searchand = ''; foreach((array)$q['search_terms'] as $term) : $term = esc_sql(like_escape($term)); $search.= "{$searchand}($wpdb->posts.post_title REGEXP '[[:<:]]{$term}[[:>:]]') OR ($wpdb->posts.post_content REGEXP '[[:<:]]{$term}[[:>:]]')"; $searchand = ' AND '; endforeach;…
WordPress 5.5 và vài code bỏ lazy load, sitemap
Khuyến mãi hai đoạn code có thể có ích trên WordPress 5.5 1 – Tắt lazyload mặc định của WordPress 5.5 function disable_template_image_lazy_loading( $default, $tag_name, $context ) { if ( ‘img’ === $tag_name && ‘wp_get_attachment_image’ === $context ) { return false; } return $default; } add_filter( ‘wp_lazy_loading_enabled’, ‘disable_template_image_lazy_loading’, 10, 3 ); Hoặc add_filter(‘wp_lazy_loading_enabled’, ‘__return_false’); 2 – Tắt chức năng site map của WordPress 5.5 add_filter( ‘wp_sitemaps_enabled’, ‘__return_false’ ); Hoặc remove_action( ‘init’, ‘wp_sitemaps_get_server’ );
Rename and clean WordPress media filenames
For the most part WordPress does a decent job of renaming and cleaning up attachment media filenames, but sometimes it’s just not quite good enough. When it comes to UTF8 characters or accents it tends to just ignore them as they’re (mostly) considered web safe. This can become an issue when third party services crawl your site and struggle with the encoding e.g. Facebook’s Sharing Debugger which is where I had trouble. Of course it’s also not great for SEO. In an Ideal world you want the featured image filename to closely mirror the post title, not be “Screenshot 2016-08-05T22:03:22.jpg”. Cleaner Filenames If all you want to do is clean…
Xoá thẻ H3 tại mục reply bình luận của WordPress
How do we remove the H3 tag for the reply-title I.D add_filter( ‘comment_form_defaults’, ‘custom_reply_title’ ); function custom_reply_title( $defaults ){ $defaults[‘title_reply_before’] = ‘<span id=”reply-title” class=”comment-reply-title”>’; $defaults[‘title_reply_after’] = ‘</span>’; return $defaults; }
Fix lỗi chiều ngang phiên bản trên điện thoại của theme Flatsome
Cách giải quyết, bạn hãy chèn vào Custom CSS dành cho Mobile chỉ với 1 dòng code nhỏ như sau: body {overflow-x:hidden;}
Hiển thị giá thấp nhất, ẩn khoảng giá đối với sản phẩm biến thể WooCommerce
add_filter( ‘woocommerce_variable_price_html’, ‘variation_price_format_min’, 9999, 2 ); function variation_price_format_min( $price, $product ) { $prices = $product->get_variation_prices( true ); $min_price = current( $prices[‘price’] ); $price = sprintf( __( ‘Chỉ từ: %1$s’, ‘woocommerce’ ), wc_price( $min_price ) ); return $price; }
Ngăn các block trong UXBuider tạo HTML khi chọn hidden
Tính năng: Ngăn các Block trong UX tạo html khi chọn hidden, mặc định Flatsome chỉ dùng css display none để ẩn những html đó. Lợi ích: Làm được 2 template riêng cho mobile và desktop, kèm theo cũng rất nhiều lợi ích khi không phải doshorte code không dùng đến. Link note https://anotepad.com/notes/kh53w2t Lưu ý: Bật cache mobile riêng kẻo trên mobile lại chẳng có gì nhé. // Add custom Theme Functions here add_filter( ‘do_shortcode_tag’, ‘add_filter_shortcode_ux_visibility’, 10, 3 ); function add_filter_shortcode_ux_visibility( $output, $tag, $attr ) { if( !isset($attr[‘visibility’]) ) return $output; if($attr[‘visibility’] == ‘hidden’) return; if( ($attr[‘visibility’] == ‘hide-for-medium’) && wp_is_mobile() ) return; elseif( ($attr[‘visibility’] == ‘show-for-small’) &&…