[워드프레스] Theme Function 추가
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<? /* 내가 추가한 Function 시작 */ /* 링크 자동으로 새창 띄우기 */ function autoblank($text) { $return = str_replace('<a', '<a target="_blank"', $text); return $return; } add_filter('the_content', 'autoblank'); add_action( 'save_post', 'wptuts_save_thumbnail' ); /* Featured Image(추천 이미지)가 없을 때 기본 이미지 보이기 */ function wptuts_save_thumbnail( $post_id ) { // Get Thumbnail $post_thumbnail = get_post_meta( $post_id, $key = '_thumbnail_id', $single = true ); // Verify that post is not a revision if ( !wp_is_post_revision( $post_id ) ) { // Check if Thumbnail exists if ( empty( $post_thumbnail ) ) { // Add thumbnail to post update_post_meta( $post_id, $meta_key = '_thumbnail_id', $meta_value = 'http://blog.ingenious.kr/default.jpg' ); } } } /* 장애시 공사중 띄우기 function maintenace_mode() { if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) { die('사이트 공사중'); } } add_action('get_header', 'maintenace_mode'); */ /* 댓글에 웹사이트 입력 제거 */ add_filter( 'comment_form_default_fields', 'comment_form_default_fields_example' ); function comment_form_default_fields_example( $fields ) { unset( $fields['url'] ); return $fields; } /* 내가 추가한 Function 끝 */ ?> |