[WordPress] 워드프레스 설치 후 설정 정리

  1. 필수 Plug-in 설치

Classic Editor (https://ko.wordpress.org/plugins/classic-editor/)
TinyMCE Advanced (https://ko.wordpress.org/plugins/tinymce-advanced/)
Code Snippets (https://ko.wordpress.org/plugins/code-snippets/)
Enlighter-Customizable Syntax Highlighter (https://ko.wordpress.org/plugins/enlighter/)


  1. 테마 설치 및 설정
    ① generatepress 테마 설치
    ② 테마 디자인 > 사용자 정의하기 > 추가 CSS
/*
/var/www/blog/wp-content/themes/generatepress/style.css
 */
body,
button,
input,
select,
textarea {
    font-family: "malgun gothic", "serif", "monospace", "gulim", "dotum", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 0.8rem;
    line-height: 1.5;
}

h1 {
    font-size: 1.8rem;
}

h2 {
    font-size: 1.2rem;
}

h3 {
    font-size: 1rem;
}

.main-navigation a {
    font-size: 1rem;
}

.menu-toggle {
    font-size: 1rem;
}

.main-navigation .main-nav ul ul li a {
    font-size: 1rem;
}

.main-title {
    font-size: 1.6rem;
}

.site-description {
    font-size: 1rem;
}

.pingback .edit-link {
    font-size: 1rem;
}

.sidebar .widget,
.footer-widgets .widget {
    font-size: 1rem;
}

.widget-title {
    font-size: 1rem;
}

.site-info {
    font-size: 1rem;
}

.top-bar {
    font-size: 1rem;
}

.generate-back-to-top,
.generate-back-to-top:visited {
    font-size: 20px;
}

/* "그 밖의 기능" 아래의 WordPress.org 링크 제거하기 */
li > a[href^="https://wordpress.org"] {
    display: none;
}

3. Snippets Plug-in 추가

① tinyMCE 폰트 추가

// 1) 폰트 추가 설정
function add_custom_fonts($init) {
    $stylesheet_url = '/wp-content/uploads/fonts/custom-fonts.css'; // font-face 설정
    if(empty($init['content_css'])) {
        $init['content_css'] = $stylesheet_url;
    } else {
        $init['content_css'] = $init['content_css'].','.$stylesheet_url;
    }
    $font_formats = isset($init['font_formats']) ? $init['font_formats'] : 'Helvetica=helvetica;Symbol=symbol;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;'; // 기본 폰트리스트에서 사용하지 않는 것 제거한 목록
    $custom_fonts = 'Gulimche=gulimche;Dotumche=dotumche;D2Coding=d2coding;NanumBarunPen=nanumbarunpen;Malgun Gothic=malgun gothic;'; // 추가 폰트를 앞쪽으로 배치
    $init['font_formats'] = $custom_fonts . $font_formats;
  return $init;
}
add_filter('tiny_mce_before_init', 'add_custom_fonts');
// 2) 프론트엔드에서 스타일시트를 로딩
function load_custom_fonts_frontend() {
    // wp_enqueue_style() 함수를 사용하는 것도 나쁘지 않다
    echo '';
}
add_action('wp_head', 'load_custom_fonts_frontend');
add_action('admin_head', 'load_custom_fonts_frontend');
// 3) 폰트 크기 설정
function add_custom_font_sizes( $initArray ){
    $initArray['fontsize_formats'] = "8px 9px 10px 11px 12px 13px 14px 15px 16px 17px 18px 19px 20px 21px 22px 23px 24px 26px 28px 30px 32px 36px 48px 60px 72px 96px";
    return $initArray;
}
add_filter( 'tiny_mce_before_init', 'add_custom_font_sizes' );

② 스마트 따옴표 비활성화

remove_filter('the_content', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
remove_filter('single_post_title', 'wptexturize');
remove_filter('the_title', 'wptexturize');
remove_filter('wp_title', 'wptexturize');

4. 자주쓰는 SQL

-- 문자열 치환
UPDATE hasu0707.wp_posts
SET post_content = REPLACE(post_content, '<!-- wp:paragraph -->\n', '');

UPDATE hasu0707.wp_posts
SET post_content = REPLACE(post_content, '\n<!-- /wp:paragraph -->', '');

UPDATE hasu0707.wp_posts
SET post_content = INSERT(post_content, 1, 0, '<!-- wp:paragraph -->\n')
WHERE (post_content NOT LIKE "%<!-- wp:paragraph -->%") AND (post_content NOT LIKE "%wp:enlighter%");

UPDATE hasu0707.wp_posts
SET post_content = CONCAT(post_content, '\n<!-- /wp:paragraph -->')
WHERE (post_content NOT LIKE "%<!-- /wp:paragraph -->%") AND (post_content NOT LIKE "%wp:enlighter%");

UPDATE hasu0707.wp_posts
SET post_content = REPLACE(post_content, '<!-- wp:paragraph -->\n\n<!-- /wp:paragraph -->', '');

-- 2byte 따옴표를 1byte 따옴표로 치환
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', 0x22);
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', 0x22);
UPDATE wp_posts SET post_content = REPLACE(post_content, '‘', 0x27);
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', 0x27);

-- 검색
SELECT * FROM wp_posts WHERE post_title LIKE "%WordPress%";
SELECT * FROM wp_posts WHERE post_title LIKE "%CentOS 7%";

위로 스크롤