Code Tự động lấy hình trong bài làm Featured Images trong wp

5/5 - (1 bình chọn)

Mở file functions.php lên (functions.php nằm trong thư mục chứa theme mặc định trong wp của bạn)

//Set anh tieu bai trong bai viet function auto_featured_thumb () { global $post ; $has_thumb = has_post_thumbnail ( $post -> ID ); if (! $has_thumb ) { $attached_image = get_children ( 'post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1' ); if ( $attached_image ) { foreach ( $attached_image as $attachment_id => $attachment ) { set_post_thumbnail ( $post -> ID , $attachment_id ); } } } } add_action ( 'the_post' , 'auto_featured_thumb' ); add_action ( 'save_post' , 'auto_featured_thumb' ); add_action ( 'draft_to_publish' , 'auto_featured_thumb' ); add_action ( 'new_to_publish' , 'auto_featured_thumb' ); add_action ( 'pending_to_publish' , 'auto_featured_thumb' ); add_action ( 'future_to_publish' , 'auto_featured_thumb' );
5/5 - (1 bình chọn)

  1. I’m not sure why but this web site iis loading very sslow for me.

    Is anyone else having this problem or is it a problem on my end?
    I’ll check back later and see if the problem still exists.

    My homepage Adtgamer.Com.Br

  2. You can definitely see your skills within the work you write.
    The world hopes for even more passionate writers like you who are not afraid to say how they believe.
    Always go after your heart.

    Fang Jifan은 흥분하여 말했습니다. “그럼 폐하 께서 과학 아카데미에 얼마나 많은 돈과 음식을 할당 하시겠습니까?”

  4. Greetings from Carolina! I’m bored at work so I decided to
    browse your site on my iphone during lunch break. I love the information you provide here and can’t wait to take a look when I
    get home. I’m shocked at how fast your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyhow, fantastic blog!

    Here is my site Gainesville IT Services

Trả lời

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 *