• Skip to main content
  • Bỏ qua primary sidebar
  • Trang chủ
  • Tút
    • Directadmin
    • WordPress
  • Code
    • Account
    • License
  • Service
  • Template
    • Open Cart
    • WordPress
      • Website doanh nghiệp
      • Website bán mỹ phẩm
      • Website bất động sản
    • Miễn phí
  • VPS
  • Check IP Location

Việt Beginner

Chia sẻ cho những ai cần đọc

Bạn đang ở:Trang chủ / Tút / Wordpress / How to set acf image field as feature image (works with custom post types too)

How to set acf image field as feature image (works with custom post types too)

04/02/2020 by Mcode Để lại bình luận

Đơn giản là thêm đoạn code này vào functions.php của theme đang dùng

<?php
 
function acf_set_featured_image( $value, $post_id, $field  ){
    
    if($value != ''){
        //Add the value which is the image ID to the _thumbnail_id meta data for the current post
        add_post_meta($post_id, '_thumbnail_id', $value);
    }
 
    return $value;
}

// acf/update_value/name={$field_name} - filter for a specific field based on it's name
add_filter('acf/update_value/name=minhhien', 'acf_set_featured_image', 10, 3);

Nhớ đổi name=”minhhien” thành name=”slug-field” của bạn nhé

Chúc các bạn thành công!

Thuộc chủ đề:Wordpress

Reader Interactions

Trả lời Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Sidebar chính

THIẾT KẾ WEBSITE UY TÍN

Thẻ

bài viết liên quan cloudlinux cloud storage cpanel csf firewall cài đặt cloudlinux cài đặt directadmin directadmin directadmin crack directadmin openlitespeed diệt malware diệt virus DKIM google clou google cloud google drive unlimited imunify imunify 360 LEMP let's encrypt lưu trữ hình ảnh ngoài hosting mariadb myportal nginx nâng cấp mariadb office 365 openlitespeed popup flatsome port login sale badge service is currently down ssl ssl giá rẻ swap system load Theme blog theme miễn phí theme tin tức theme tạp chí tường lửa warning wildcard ssl woocommerce wpml xử lý mã độc

Copyright © 2021 · MH Solutions · Đăng nhập