코드 및 디자인 레퍼런스
-
워드프레스 구텐버그 로드 비활성화
function smartwp_remove_wp_block_library_css(){ wp_dequeue_style( 'wp-block-library' ); wp_dequeue_style( 'wp-block-library-theme' ); } add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css' );
특정 목적에 따라 워드프레스의 Gutenberg 에디터가 불필요할 경우가 있다. 그럴때 보통 Classic Editor 를 설치하기도 한다. 하지만 프론트엔드에서는 여전히 Gutenberg 관련 스크립트가 로드 되는것을 볼 수 있다. 확실히 Gutenberg를 비활성화하여 사이트 로드를 조금 더 빠르게 하고자할때 사용하면 좋다.
8월 6, 2021
-
the_content() 본문 이미지 추출
function get_first_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches[1][0]; return $first_img; }
특성 이미지를 사용하지 않을때 목록에서 썸네일로 활용
6월 18, 2021
-
Search Meter와 Relevanssi 연동
function switch_search_meter_priority() { remove_filter( 'the_posts', 'tguy_sm_save_search', 20 ); add_filter( 'the_posts', 'tguy_sm_save_search', 100 ); } add_action( 'init', 'switch_search_meter_priority' );
Search Meter 업데이트 중단 및 보안 이슈 발생하여 코드 폐기
6월 16, 2021