Hook cho bài viết trong WordPress
Hôm nay mình sẽ chia sẻ cho các bạn một số đoạn Hook cho Bài viết (Post) trong WordPress không sử dụng Plugin cực kỳ đơn giản.
Khuyến cáo: Nên sử dụng Theme Child để viết code
Xem thêm: Hiển thị bài viết liên quan trong chi tiết bài viết WordPress
Các hook nằm trong Element blog post của Flatsome
Trong element Blog Post của flatsome thì hiện tại có 2 hook là:
flatsome_blog_post_before flatsome_blog_post_after
flatsome_blog_post_before flatsome_blog_post_after
//* Customize the entry meta in the entry footer add_filter( 'genesis_post_meta', 'post_meta_filter' ); function post_meta_filter( $post_meta ) { $post_meta = 'Posted on [post_date] by [post_author_posts_link] under [post_categories before=""] with tag [post_tags before=""][post_edit]'; return $post_meta; }
//* Customize the entry meta in the entry footer add_filter( 'genesis_post_meta', 'post_meta_filter' ); function post_meta_filter( $post_meta ) { $post_meta = 'Posted on [post_date] by [post_author_posts_link] under [post_categories before=""] with tag [post_tags before=""][post_edit]'; return $post_meta; }
//* Customize the entry meta in the entry footer add_filter( 'genesis_post_meta', 'post_meta_filter' ); function post_meta_filter( $post_meta ) { $post_meta = 'Posted on [post_date] by [post_author_posts_link] under [post_categories before=""] with tag [post_tags before=""][post_edit]'; return $post_meta; }
//* Customize the entry meta in the entry footer add_filter( 'genesis_post_meta', 'post_meta_filter' ); function post_meta_filter( $post_meta ) { $post_meta = 'Posted on [post_date] by [post_author_posts_link] under [post_categories before=""] with tag [post_tags before=""][post_edit]'; return $post_meta; }
//* Customize the entry meta in the entry footer add_filter( 'genesis_post_meta', 'post_meta_filter' ); function post_meta_filter( $post_meta ) { $post_meta = 'Posted on [post_date] by [post_author_posts_link] under [post_categories before=""] with tag [post_tags before=""][post_edit]'; return $post_meta; }
.add_to_cart_mobile { position: absolute; bottom: 0; z-index: 999999999999; /* display: flex; */ width: 100%; display: none; } .add_to_cart_mobile button#add_to_cart_mobile { width: 50%; margin: 0 !important; border: none; line-height: 36px; background: #ddd; font-size: 14px; color: #ee4e2e; text-transform: capitalize; font-weight: 400; position: relative; display: inline-block; } .add_to_cart_mobile a.button.alt.buy-now { width: 50%; font-size: 14px; margin-right: 0; float: right; }
Bây giờ mình sẽ bắt đầu code luôn cho các bạn không phải đọc dài dòng nữa nhé.
Thêm Hook vào trước tiêu đề bài viết

Thêm Hook vào sau tiêu đề bài viết

Các hook nằm trong single của Flatsome
Tiếp theo mình sẽ hướng dẫn các bạn 1 số đoạn Hook nằm trong chi tiết bài viết. Thực ra nó cũng giống như 2 đoạn code trên thôi, các bạn cùng theo dõi nhé.
Thêm nội dung vào đầu bài viết

Thêm nội dung vào giữa bài viết

Thêm nội dung vào sau bài viết

Vậy là đã xong rồi. Các bạn vào lại trang thanh toán rồi F5 lại để xem thay đổi nhé (Bạn hãy xóa Cache trước nếu bạn dùng cache nhé, hoặc bạn Ctrl + F5 cũng được)
Xem thêm: Tùy biến trang thanh toán (checkout) Woocommerce
Xem thêm: Làm đẹp form trong trang thanh toán (checkout) Woocommerce
Trong quá trình thay đổi text button trang thanh toán mà bạn gặp lỗi thì hãy comment cho ITCODEWP.COM biết, mình sẽ hướng dẫn hỗ trợ bạn.
Chúc các bạn thành công!
Nguồn: https://itcodewp.com/