WordPress Define Add

📌 define을 추가해야 하는 파일 및 설명

WordPress에서 define('WP_POST_REVISIONS', 2);define('EMPTY_TRASH_DAYS', 7); 같은 설정을 추가하려면 wp-config.php 파일을 사용해야 합니다.


1️⃣ wp-config.php 파일의 위치

wp-config.php는 WordPress 설치 디렉터리의 루트(최상위)에 위치합니다.

📍 서버별 경로 예시

  • Apache (Ubuntu/Linux)/var/www/html/wordpress/wp-config.php
  • Nginx (Ubuntu/Linux)/usr/share/nginx/wordpress/wp-config.php
  • Windows (XAMPP)C:\xampp\htdocs\wordpress\wp-config.php

📌 이 파일은 WordPress의 핵심 설정을 포함하고 있으며, 데이터베이스 연결 정보 및 디버깅 옵션도 여기에 저장됨.


2️⃣ wp-config.php 파일에서 define 추가하기

wp-config.php 파일을 열고, 다음 코드를 추가하면 됩니다.
이 설정들은 반드시 아래 위치에 추가해야 합니다!

// 게시글 개정판(리비전) 최대 2개로 제한
define('WP_POST_REVISIONS', 2);

// 휴지통을 7일 후 자동 비우기
define('EMPTY_TRASH_DAYS', 7);

추가 위치:
파일에서 /* That's all, stop editing! Happy publishing. */ 주석 위에 추가해야 합니다.

📌 올바른 코드 위치 예제 (wp-config.php)

<?php
define('DB_NAME', 'database_name');
define('DB_USER', 'database_user');
define('DB_PASSWORD', 'database_password');
define('DB_HOST', 'localhost');

define('WP_DEBUG', false);

// 추가할 define 설정들
define('WP_POST_REVISIONS', 2);
define('EMPTY_TRASH_DAYS', 7);

/* That's all, stop editing! Happy publishing. */

3️⃣ define 설정 설명

설정설명
WP_POST_REVISIONS게시글 개정판(리비전) 최대 개수 설정 2로 설정하면 최신 2개의 개정판만 유지됨 (기본값: 무제한)
EMPTY_TRASH_DAYS휴지통 비우기 자동 실행 7로 설정하면 삭제된 게시글과 미디어 파일이 7일 후 자동 삭제됨 (기본값: 30일)

4️⃣ wp-config.php 파일의 역할

wp-config.php 파일은 WordPress의 핵심 환경 설정을 담당하는 파일입니다.
이 파일은 사이트가 실행될 때 가장 먼저 로드되며, 주요 역할은 다음과 같습니다.

역할설명
데이터베이스 설정DB 접속 정보 (DB_NAME, DB_USER, DB_PASSWORD)
디버깅 옵션WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY
성능 최적화WP_POST_REVISIONS, EMPTY_TRASH_DAYS
보안 설정DISALLOW_FILE_EDIT (관리자에서 파일 수정 금지)
파일 업로드 크기 제한WP_MEMORY_LIMIT, UPLOAD_MAX_FILESIZE

📌 결론

wp-config.php 파일을 수정해야 함 (/wordpress/wp-config.php)
게시글 개정판을 2개로 제한하려면define('WP_POST_REVISIONS', 2);
휴지통을 7일 후 자동 비우려면define('EMPTY_TRASH_DAYS', 7);
/* That's all, stop editing! Happy publishing. */ 위에 추가해야 정상 작동

🚀 이 설정을 활용하면 WordPress 성능을 최적화하고 데이터베이스 부담을 줄일 수 있습니다!

wp-config.php 정의 추가하기 위해서 예제

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/documentation/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */


////////////////////////////////////////////////////////////////////////////
// 포스트(글) 리비전 수
define('WP_POST_REVISIONS', 2);

// 휴지통 비우는 날짜 기준 정하기, 7일 이내에 삭제
define('EMPTY_TRASH_DAYS', 7);

/////////////////////////////////////////////////////////////////////////////


/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

Leave a Reply

Your email address will not be published. Required fields are marked *