Languages: เฆฌเฆพเฆเฆฒเฆพ โข English โข Espaรฑol โข ๆฅๆฌ่ช ํ๊ตญ์ด โข Portuguรชs do Brasil โข ะ ัััะบะธะน โข เนเธเธข โข ไธญๆ(็ฎไฝ) โข ไธญๆ(็น้ซ) โข (Add your language)
์ด ๋ฌธ์๋ ์๋ํ๋ ์ค ํ ๋ง ๊ฐ๋ฐ์ ๊ดํ ๋ฌธ์์ ๋๋ค. ์ด๋ป๊ฒ ์ค์นํ๊ณ ํ ๋ง๋ฅผ ์ฌ์ฉํ๋์ง ์์ธํ ์๊ณ ์ถ๋ค๋ฉด ํ ๋ง ์ฌ์ฉ๋ฒ ์ ์ดํด๋ณด์ธ์. ์ด ๊ธ์์๋ ํ ๋ง ์ฌ์ฉ๋ฒ์ ๋ํด ๋ค๋ฃจ์ง ์์ต๋๋ค. ์๋ํ๋ฉด ์ด ํญ๋ชฉ์ ์คํ๋ ค ์๋ก์ด ํ ๋ง๋ฅผ ์ฐพ๊ณ ํ ๋ง๋ฅผ ํ์ฑํํ๋ ๋ฐฉ๋ฒ๋ณด๋ค ๋๋ง์ ํ ๋ง๋ฅผ ๊ตฌ์ถํ๊ธฐ ์ํด ์ฝ๋๋ฅผ ์์ฑํ๋ ๊ธฐ์ ์ ์ธ ์ธก๋ฉด์ ์ค๋ช ํ๊ณ ์์ต๋๋ค.
์๋ํ๋ ์ค ํ ๋ง๋ ์๋ํ๋ ์ค ์ฌ์ดํธ์ ๋์์ธ๊ณผ ๊ธฐ๋ฅ์ ๋ฌถ์ด ๋ง๋ ํ์ผ์ ๋๋ค. ๊ฐ ํ ๋ง๋ ๊ณง๋ฐ๋ก ์์ ์ ์น์ฌ์ดํธ ๋ชจ์์ ๋ณ๊ฒฝํ ์ ์๋๋ก ์ฌ์ดํธ ์์ ์๋ฅผ ์ํด ๋ง์ ์ ํ๊ถ์ ์ ๊ณตํฉ๋๋ค.
๋น์ ์ ํด๋ผ์ด์ธํธ ํ๋ก์ ํธ๋ ์๋ํ๋ ์ค ํ ๋ง ๋๋ ํ ๋ฆฌ์ ์ ์ถํ๊ธฐ ์ํด, ์์ ์ด ์ฌ์ฉํ๋ ์๋ํ๋ ์ค์ ํ ๋ง๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค. ๊ทธ๋ผ ์ ์๋ํ๋ ์ค ํ ๋ง๋ฅผ ๋ง๋ค๋ ค๊ณ ํ ๊น์?
์ฌ๋น ๋ฅด๊ฒ ์ฌ๋ฌ ์ฌ์ดํธ์ ๋ ์ด์์์ ๋ฐ๊พธ๊ฑฐ๋ ํ์ฉํ๊ธฐ ์ํด, ์คํ์ผ ์ค์์ฒ๋ฅผ ํตํด ์ฌ์ดํธ ์์ ์๋ ์ฌ์ดํธ์ ๋ชจ์์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
๊ทธ๋ฐ์๋, ์๋ํ๋ ์ค ํ ๋ง์๋ ๋ง์ ์ฅ์ ์ด ์์ต๋๋ค.
์ ์์ ๋ง์ ์๋ํ๋ ์ค ํ ๋ง๋ฅผ ๊ตฌ์ถํด์ผ๋ง ํ๋๊ฐ? ๊ทธ๊ฒ์ด ์ ๋ง ์๊ณ ์ถ์ต๋๋ค.
์๋ํ๋ ์ค ํ ๋ง๋ ๋ค์๊ณผ ๊ฐ์ ๊ธฐ์ค์ ์ฌ์ฉํ์ฌ ์ฝ๋ฉํด์ผ ํฉ๋๋ค:
์๋ํ๋ ์ค ํ ๋ง๋ wp-content/themes/ ๋๋ ํ ๋ฆฌ์ ์๋ธ(ํ์)๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค. ํ ๋ง ์๋ธ๋๋ ํ ๋ฆฌ์๋ ํ ๋ง ์คํ์ผ์ํธ ํ์ผ, ํ ํ๋ฆฟ ํ์ผ, ์ต์ ๊ธฐ๋ฅ ํ์ผ (functions.php), ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ, ๊ทธ๋ฆฌ๊ณ ์ด๋ฏธ์ง ๊ฐ์ ๊ฒ๋ค์ด ๋ชจ๋ ํฌํจ๋์ด ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, "test" ๋ผ๋ ์ด๋ฆ์ ํ ๋ง๋ wp-content/themes/test/ ๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค. ํ ๋ง ์ด๋ฆ์ ์ซ์๋ฅผ ์ฌ์ฉํ์ง ๋ง์ธ์, ์ด๊ฒ์ ์ฌ์ฉ ๊ฐ๋ฅํ ํ ๋ง ๋ชฉ๋ก์ ํ์๋์ง ์๋๊ฒ์ ๋ฐฉ์งํ๊ธฐ ์ํจ์ ๋๋ค.
์๋กญ๊ฒ ์ค์นํ ์๋ํ๋ ์ค์๋ ๊ฐ๊ฐ์ ๊ธฐ๋ณธ ํ ๋ง๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. ์์ ๋ง์ ํ ๋ง ํ์ผ์ ๋น๋ํ๋ ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ ๊ธฐ๋ณธ ํ ๋ง์ ํ์ผ์ ํ์ด๋ณด๋ ๊ฒ์ ๋๋ค.
๋น์ฃผ์ผ ๊ฐ์ด๋์ ๊ฒฝ์ฐ, infographic ์ฐธ์กฐ: http://yoast.com/wordpress-theme-anatomy/
์๋ํ๋ ์ค ํ ๋ง๋ ๋ณดํต ์ด๋ฏธ์ง์ ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ ์ด์ธ์๋, ์ธ๊ฐ์ง ์ข ๋ฅ์ ์ฃผ์ ํ์ผ๋ก ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค. ์ฒซ๋ฒ์งธ๋ style.css ๋ผ๋ ํ์ผ์ ๋๋ค, ์น์ฌ์ดํธ ํ์ด์ง์ ํ๋ฆฌ์ ํ ์ด์ (๋น์ฃผ์ผ ๋์์ธ๊ณผ ๋ ์ด์์)์ ์ ์ดํฉ๋๋ค. ๋๋ฒ์งธ๋ (functions.php) ๋ผ๋ ์ต์ ๊ธฐ๋ฅ ํ์ผ ์ ๋๋ค. ๋์ผ๋ก ์ฌ์ดํธ์ ํ์ด์ง๋ฅผ ๋ํ๋ด๊ธฐ ์ํด ์๋ํ๋ ์ค ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ์ ๋ณด๋ฅผ ๋ง๋ค๊ณ ์ ์ดํ๋ ํ ํ๋ฆฟ ํ์ผ์ ๋๋ค. ๊ฐ๊ฐ ์ดํด๋ณด๋๋ก ํฉ์๋ค.
Child ํ ๋ง๋ ์ค๋ก์ง style.css ํ์ผ๊ณผ ๋ช๊ฐ์ ์ด๋ฏธ์ง๋ง ํฌํจํ๋ ๊ฐ๋จํ ํ ๋ง์ ๋๋ค. Parent ์ญํ ์ ํ๋ ํ ๋ง์ Child์ด๊ธฐ ๋๋ฌธ์ ๊ฐ๋ฅํฉ๋๋ค.
Child ํ ๋ง๋ฅผ ์ํ ์์ธํ ์๋ด๋, Child ํ ๋ง ๋๋ ์ด ํ๋ฅญํ ๊ฐ์์ ์ ์๋ op111์ ๋ณด์ธ์.
ํ ๋ง์ ๋ํ CSS ์คํ์ผ ์ ๋ณด ์ด์ธ์, style.css ๋ ์ฃผ์์ ํํ๋ก ํ ๋ง์ ๋ํ ์ธ๋ถ ์ฌํญ์ ์ ๊ณตํฉ๋๋ค. ์คํ์ผ์ํธ๋ ๋ฐ๋์ ์ฃผ์์ ํํ๋ก ํ ๋ง์ ๋ํ ์ธ๋ถ ์ฌํญ์ ์ ๊ณตํด์ผํฉ๋๋ค. ๋๊ฐ์ ํ ๋ง๋ ๋์ผํ ๋ด์ฉ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค ์์ ์ ํค๋์ ์ฃผ์์ ๋จ๊ฒจ์ผ ํฉ๋๋ค, ์ด์ฒ๋ผํ ๋ง ์ ํ ๋ํ์์์์ ๋ถํฐ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ๋ง์ผ ๊ธฐ์กด์ ๊ฒ์ ๋ณต์ฌํ์ฌ ์์ ๋ง์ ํ ๋ง๋ฅผ ๋ง๋ค ๊ฒฝ์ฐ, ๋จผ์ ์ด ์ ๋ณด๋ถํฐ ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค.
๋ค์์ ์คํ์ผ์ํธ์ ์ฒซ ๋ช์ค์ ์์ ๋๋ค, "Twenty Ten" ํ ๋ง์ ๋ํ ์คํ์ผ์ํธ ํค๋๋ฅผ ๋ถ๋ฌ์ต๋๋ค:
/* Theme Name: Twenty Ten Theme URI: http://wordpress.org/ Description: The 2010 default theme for WordPress. Author: wordpressdotorg Author URI: http://wordpress.org/ Version: 1.0 Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional) License: License URI: General comments (optional). */
์ฃผ์: ์ ์์๋ก ์ฌ์ฉ๋๋ ์ด๋ฆ์ wordpress.org ์ Theme Author ์ ๊ฐ์ ์ฌ์ฉ์ ์ด๋ฆ์ผ๋ก ํ๋๊ฒ์ ์ถ์ฒํฉ๋๋ค. ๋น๋ก ์ ์์์ ์ค์ ์ด๋ฆ์ ํ ์๋ ์๊ฒ ์ง๋ง, ์ ํ์ Theme Author ์ ๋๋ค.
style.css ์ ์ฃผ์ ํค๋ ๋ถ๋ถ์ ์ฝ์ด๋ค์ฌ ์๋ํ๋ ์ค์ ๋ชจ๋ ์ค์น๋ ๋ค๋ฅธ ํ ๋ง์ ํจ๊ป ์ฌ์ฉ๊ฐ๋ฅํ ํ ๋ง ์ต์ ์ผ๋ก ๊ด๋ฆฌ์ ํจ๋ ์๋ ๋์์ธ > ํ ๋ง์ ํ์ ํ ์ ์๊ฒ ํฉ๋๋ค.
ํ ๋ง๋ ์ ํ์ ์ผ๋ก ํ์ ๋๋ ํ ๋ฆฌ ํ ๋ง์ ์๋ ํจ์ ํ์ผ์ธ functions.php ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด ํ์ผ์ ๊ธฐ๋ณธ์ ์ผ๋ก ํ๋ฌ๊ทธ์ธ ๊ณผ ๊ฐ์ ์ญํ ์ ํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ฌ์ฉ์ค์ธ ํ ๋ง๊ฐ ์์ ๊ฒฝ์ฐ, ๊ทธ๊ฒ์ ์๋์ผ๋ก ์๋ํ๋ ์ค๋ฅผ ์ด๊ธฐํํ๋ ๋์ ๋ก๋ฉ ๋ฉ๋๋ค(๊ด๋ฆฌ์ ํ์ด์ง ๋ฐ ์ธ๋ถ ํ์ด์ง ๋ชจ๋์). ์ด ํ์ผ์ ์ฌ์ฉํ ๊ฒ์ ์ ์ํฉ๋๋ค:
๊ธฐ๋ณธ์ ์ผ๋ก ์๋ํ๋ ์ค ํ ๋ง๋ ์ด๋ฌํ ๊ธฐ๋ฅ์ ๋๋ถ๋ถ์ ์ ์ํ๋ functions.php ํ์ผ์ด ํฌํจ๋์ด ์๊ธฐ ๋๋ฌธ์ ๋น์ ์ ๊ทธ๊ฒ์ ๊ทธ๋๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์๋ functions.php ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํ๋ฌ๊ทธ์ธ ๊ธฐ๋ฅ์ ํฉ๋๋ค. ์ด ํ์ผ๊ณผ ํจ๊ป ํ ์ ์๋ ์ผ์ ๋ํ ์์ธํ ๋ด์ฉ์ Function_Reference ๋ชฉ๋ก์ ๋ณด๋๊ฒ์ด ๊ฐ์ฅ ์ข์ต๋๋ค.
ํ ํ๋ฆฟ์ ๋ฐฉ๋ฌธ์๊ฐ ์์ฒญํ ํ์ด์ง๋ฅผ ์์ฑํ๋ ๋ฐ ์ฌ์ฉ๋๋ PHP ์์ค ํ์ผ์ด๋ฉฐ, HTML๋ก ์ถ๋ ฅ๋ฉ๋๋ค. ํ ๋ง์ ์ผ๋ถ๋ก ์ ์ํ ์์๋ ๋ค์ํ ํ ํ๋ฆฟ์ ์ดํด ๋ด ์๋ค.
์๋ํ๋ ์ค๋ ์ฌ์ดํธ์ ๋ค์ํ ์ธก๋ฉด์ ๋ํด ๋ณ๋์ ํ ํ๋ฆฟ์ ์ ์ํ ์ ์์ต๋๋ค. ๊ทธ๊ฒ์ด ์๋ฒฝํ๊ฒ ์๋ํ๋ ค๋ฉด ๊ทํ์ ์ฌ์ดํธ์ ๋ํ ๋ชจ๋ ๋ค๋ฅธ ํ ํ๋ฆฟ ํ์ผ์ ๊ฐ์ง๊ณ ์์ด์ผ ํ์ง๋ง, ํ์๋ ์๋๋๋ค. ํ ํ๋ฆฟ์ ํ ํ๋ฆฟ ๊ณ์ธต ๊ตฌ์กฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํน์ ํ ๋ง์ ๋ฐ๋ผ ์ ํํ๊ณ ์์ฑ๋ฉ๋๋ค.
ํ ๋ง ๊ฐ๋ฐ์๋, ํ ํ๋ฆฟ์ ์ฌ์ฉํ์ฌ ๊ตฌํํ๋ ค๋ ์ฌ์ฉ์ ์ ์ ๋ถ๋ถ์ ์ ํํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๊ทน๋จ์ ์ธ ๊ฒฝ์ฐ, ๋น์ ์ ์ฌ์ดํธ์ ํ์๋๋ ๋ชจ๋ ์์ฑ๋ ํ์ด์ง์ ๋ํ ํ ํ๋ฆฟ์ผ๋ก index.php๋ผ๋ ํ๋์ ํ ํ๋ฆฟ ํ์ผ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋ณด๋ค ์ผ๋ฐ์ ์ธ ์ฌ์ฉ์ ์ต๋ํ ์ฌ์ฉ์ ์ ์๋ฅผ ํ์ฉํ๋๋ก ๋ค๋ฅธ ํ ํ๋ฆฟ ํ์ผ์ด ๋ค๋ฅธ ๊ฒฐ๊ณผ๋ฅผ ์์ฑํ๋ ๊ฒ์ ๋๋ค.
๋ค์์ ์๋ํ๋ ์ค์์ ํ์ฉํ๋ ํ ๋ง ํ์ผ์ ๋ชฉ๋ก์ ๋๋ค. ๋ฌผ๋ก , ๋น์ ์ ํ ๋ง๋ ๋ค๋ฅธ ์คํ์ผ ์ํธ, ์ด๋ฏธ์ง ๋๋ ํ์ผ์ ํฌํจํ ์ ์์ต๋๋ค. ๋จ์ง, ์๋์ ๋ด์ฉ์ ์๋ํ๋ ์ค์ ํน๋ณํ ์๋ฏธ๋ฅผ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ๋ง ๋ช ์ฌํ์ธ์ - ํ ํ๋ฆฟ ๊ณ์ธต ๊ตฌ์กฐ ์์ ์์ธํ ๋ด์ฉ์ ์ฐธ์กฐํ์ญ์์ค.
์ด๋ฌํ ํ์ผ๋ค์ ์๋ํ๋ ์ค์์ ํน๋ณํ ์๋ฏธ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค. ์๋ํ๋ฉด ๊ทธ๊ฒ๋ค์ ๊ฐ๋ฅํํ ๊ฒฝ์ฐ์ ๋ฐ๋ผ์๋ ํ ํ๋ฆฟ ๊ณ์ธต๊ตฌ์กฐ ๋ฐ true ๋ฅผ ๋ฐํํ๋ ์กฐ๊ฑด๋ถ ํ๊ทธ ์ ๋์ํ์ฌ index.php ๋ฅผ ๋์ ํด ์ฌ์ฉ๋๊ธฐ ๋๋ฌธ์ ๋๋ค. ์๋ฅผ ๋ค๋ฉด, ๋ง์ผ ํ๋์ ๊ฒ์๋ฌผ์ด ํ์๋๋ ๊ฒฝ์ฐ, is_single() ํจ์๋ 'true' ๋ฅผ ๋ฐํ, ๊ทธ๋ฆฌ๊ณ , ๋ง์ผ ๊ทธ๊ฒ์ด ํ์ฑํ๋ ํ ๋ง ์์์ single.php ํ์ผ์ด ์๋ค๋ฉด, ํ ํ๋ฆฟ์ ํ์ด์ง๋ฅผ ์์ฑํฉ๋๋ค.
์์ฃผ ์ต์ํ์ผ๋ก, ์๋ํ๋ ์ค ํ ๋ง๋ ๋ ๊ฐ์ ํ์ผ๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค :
์ ๋ ํ์ผ์ด ์๋ ํ ๋ง ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํ์ธ์. index.php ํ ํ๋ฆฟ ํ์ผ ์ ๋งค์ฐ ์ ์ฐํ๊ฒ ๋์ํฉ๋๋ค. ์ด๊ฒ์ ํค๋, ์ฌ์ด๋๋ฐ, ํํฐ, ์ฝํ ์ธ , ์นดํ ๊ณ ๋ฆฌ, ์์นด์ด๋ธ, ๊ฒ์, ์ค๋ฅ, ๊ทธ๋ฆฌ๊ณ ์๋ํ๋ ์ค์์ ๋ง๋ ๋ค๋ฅธ ํ์ด์ง์ ๋ํ ๋ชจ๋ ์ฐธ์กฐ๋ฅผ ํฌํจํ๋๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋๋, ํ ํ๋ฆฟ ํ์ผ๋ค๋ก ๋ชจ๋ํ(๋ถ๋ฆฌ)ํ์ฌ ์ผ๋ จ์ ์์ ๋ค์ ๊ฐ๊ฐ ๋ถ๋ด์ํฌ ์๋ ์์ต๋๋ค. ๋ง์ฝ ๋น์ ์ด ๋ค๋ฅธ ํ ํ๋ฆฟ ํ์ผ๋ค์ ์ ๊ณตํ์ง ์๋๋ค๋ฉด, ์๋ํ๋ ์ค๋ ๊ธฐ๋ณธ ๋ฒ์ ์ ์ฌ์ฉํ ๊ฒ์ ๋๋ค. ์๋ฅผ ๋ค์ด, ๋ง์ฝ ๋น์ ์ด comments.php ํ ํ๋ฆฟ ํ์ผ์ด ์์ด๋ ์๋ํ๋ ์ค๋ ์๋์ผ๋ก Template Hierarchy์ ์ํด wp-comments.php ํ ํ๋ฆฟ ํ์ผ์ ์ฌ์ฉํ ๊ฒ์ ๋๋ค. (Note: As of version 3.0, the default files aren't guaranteed to be present or to be the same as they have been. It's much safer to supply your own template files.)
์ผ๋ฐ์ ์ธ ํ ํ๋ฆฟ ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค :
ํ ํ๋ฆฟ ํ์ผ์ ์ฌ์ฉํ ๋, ๋น์ ์ index.php ๋ง์คํฐ ํ์ผ์ ํ ํ๋ฆฟ ํ๊ทธ๋ฅผ ๋ฃ์ด์ ์ต์ข ์ ์ผ๋ก ์์ฑ๋ ํ์ด์ง์ ๋ํ๋ด๊ฒ ํ๊ณ ์ถ์ ์ฅ์์ ์ธํด๋ฃจ๋ ํ ์ ์์ต๋๋ค.
์ฌ๊ธฐ include ๊ฐ ์ฌ์ฉ๋ ์ :
<?php get_sidebar(); ?> <?php get_footer(); ?>
์ด๋ฌํ ๋ค์ํ ํ ํ๋ฆฟ์ด ์๋ํ๋ ๋ฐฉ๋ฒ์ ๋ํ ๋ฐฉ๋ฒ๊ณผ ์ด๋ค ์์ ์๋ก ๋ค๋ฅธ ์ ๋ณด๋ฅผ ์์ฑํ๊ธฐ ์ํ ๋ ๋ง์ ์ ๋ณด๋ ํ ํ๋ฆฟ ๋ฌธ์๋ฅผ ์ฝ์ด๋ณด์ญ์์ค.
๊ฐ๊ฐ์ ํ์ด์ง ํ ํ๋ฆฟ ํ์ผ๋ค์ ๋น์ ์ ํ ๋ง๋๋ ํ ๋ฆฌ์์ ์ฐพ์ ์ ์์ต๋๋ค. ํ์ด์ง๋ฅผ ์ํ ์ฌ์ฉ์ ์ ์ ํ ํ๋ฆฟ์ ๋ง๋๋ ค๋ฉด ํ์ผ์ ์์ฑํด์ผ๋ง ํฉ๋๋ค. ์ฐ๋ฆฌ๋ค์ ํ์ด์ง๋ฅผ ์ํ ์ฒซ๋ฒ์งธ ํ์ด์ง ํ ํ๋ฆฟ ํ์ผ์ snarfer.php ๋ผ๊ณ ํ๊ฒ ์ต๋๋ค. snarfer.php ํ์ผ์ ์ต์๋จ์ ์๋ ๋ฌธ์ฅ์ ๋ถ์ฌ ๋ฃ์ผ์ธ์ :
<?php /* Template Name: Snarfer */ ?>
์ ์ฝ๋๋ snarfer.php ํ์ผ์ "Snarfer" ๋ผ๋ ์ด๋ฆ์ ํ ํ๋ฆฟ์ด๋ผ๊ณ ์ ์ํ ๊ฒ์ ๋๋ค. ์์ฐ์ฐํ "Snarfer" ์๋ฆฌ์๋ ํ์ด์ง ํ ํ๋ฆฟ ์ด๋ฆ์ ๋ฐ๊พธ๊ธฐ ์ํด์๋ ๋ค๋ฅธ ๋ฌธ์๋ค๋ก ๋ฐ๊ฟ์ผ ํ๊ฒ ์ฃ . ์ด ํ ํ๋ฆฟ์ ์ด๋ฆ์ ํ ๋ง ํธ์ง๊ธฐ์์ ์ด ํ์ผ์ ํธ์งํ๊ธฐ ์ํ ๋งํฌ๋ก ๋ํ๋๊ฒ ๋ฉ๋๋ค.
ํ์ผ๋ช ์ .php ํ์ฅ์์ ํจ๊ป ๋๋ถ๋ถ์ ๊ฒฝ์ฐ์ ์ด๋ค ์ด๋ฆ์ผ๋ก ์ง์ด๋ ๋ฌด๋ฐฉํฉ๋๋ค. ( ์์ฝ๋ ํ ๋ง ํ์ผ๋ช ์ ๋์์๋ ์ด๋ฆ๋ค์ ์ฌ์ฉํ์ง ๋ง์ธ์. ์๋ํ๋ฉด ์ด ์ด๋ฆ๋ค์ ํน์ํ ๋ชฉ์ ์ ์ํด ์๋ํ๋ ์ค์์ ์ฌ์ฉํ๋ ํ์ผ๋ช ์ด๊ธฐ ๋๋ฌธ์ ๋๋ค).
What follows the above five lines of code is up to you. ๊ทธ์ธ์ ๋น์ ์ด ์์ฑํ ์ฝ๋๋ค์ Snarfer ํ์ด์ง ํ ํ๋ฆฟ์ ์ฌ์ฉํ๋ ํ์ด์ง๋ฅผ ์ด๋ป๊ฒ ํ์(ํํ)ํ ๊ฒ์ธ์ง๋ฅผ ์ ์ดํ ๊ฒ์ ๋๋ค. ์ด๋ฅผ ์ํด ๋น์ ์ด ์ฌ์ฉํ ์ ์๋ ๋ค์ํ ์๋ํ๋ ์ค ํ ํ๋ฆฟ ํจ์๋ค์ ์ค๋ช ์ ๋ณด๋ ค๋ฉด Template Tags ์ ๋ณด์ธ์.
๋ค๋ฅธ ํ ํ๋ฆฟ(์๋ง๋ page.php ํน์ index.php)์ ์ผ๋ถ๋ฅผ snarfer.php ์ ๋ณต์ฌํ๋ ๊ฒ์ด ์ข ๋ ํธ๋ฆฌํ ์ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ ๋ค ์์ 5์ค ์ฝ๋๋ฅผ ํ์ผ์ ์์์ ์ ์ถ๊ฐํ์ธ์. ๊ทธ ์ํ์์ ๋น์ ์ HTML๊ณผ PHP ์ฝ๋๋ฅผ ์์ ํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ด ์ฒ์๋ถํฐ ์๋ก ์์ฑํ๋ ๊ฒ ๋ณด๋ค ํธ๋ฆฌํ ๊ฒ์ ๋๋ค. ์์ ๋ ์๋์ ์์ต๋๋ค.
ํ์ด์ง ํ ํ๋ฆฟ์ ์์ฑํ๊ณ , ํ ๋ง ๋๋ ํ ๋ฆฌ์ ์์น์์ผ ๋์ผ๋ฉด ํ์ด์ง๋ฅผ ์์ฑ/ํธ์ง ํ ๋ ๊ทธ ํ ํ๋ฆฟ์ ์ ํํ ์ ์๊ฒ ๋ฉ๋๋ค. (์ฐธ๊ณ : ํ์ด์ง๋ฅผ ์์ฑ/ํธ์งํ ๋ ํ์ด์ง ํ ํ๋ฆฟ ์ต์ ์ ์ ๋ฐฉ๋ฒ๊ณผ ๊ฐ์ด ์ต์ ํ๋ ์ด์ ํ ํ๋ฆฟ์ ์ ์ํด ๋์ง ์์ผ๋ฉด ๋ํ๋์ง ์์ต๋๋ค).
์๋ํ๋ ์ค๋ ๋ค๋ฅธ ์ฟผ๋ฆฌ ํ์ ์ ๋ฐ๋ผ ๋ค๋ฅธ ํ ํ๋ฆฟ์ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค. ์ด๊ฑธ ํ๋ ๋ฐฉ๋ฒ์ ๋ ๊ฐ์ง๊ฐ ์์ต๋๋ค : ํ ํ๋ฆฟ ๊ณ์ธต ๊ตฌ์กฐ์ ํ ๋ถ๋ถ์ผ๋ก ๋ง๋๋ ๊ฒ๊ณผ,ํ ํ๋ฆฟ ํ์ผ์ ๋ฃจํ ์์ Conditional Tags ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ํ ํ๋ฆฟ ๊ณ์ธต ๊ตฌ์กฐ์ ์ด์ฉํ๊ธฐ ์ํด์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํน์ ๋ชฉ์ ํ ํ๋ฆฟ ํ์ผ์ ์ ๊ณตํด์ผ ํฉ๋๋ค. ์ด๊ฒ์ ์๋์ ์ผ๋ก index.php ๋ฅผ ์ค๋ฒ๋ผ์ด๋ํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ๋ง์ฝ ๋น์ ์ ํ ๋ง๊ฐ category.php ๋ผ๊ณ ๋ถ๋ฅด๋ ํ ํ๋ฆฟ ํ์ผ์ ์ ๊ณตํ ๋, ์นดํ ๊ณ ๋ฆฌ๊ฐ ์ฟผ๋ฆฌ๋๋ฉด index.php ๋์ category.php ๋ฅผ ๋ถ๋ฌ์ฌ ๊ฒ์ ๋๋ค. ๋ง์ฝ category.php ํ์ผ์ด ์กด์ฌํ์ง ์๋ค๋ฉด, index.php ๋ฅผ ์ฌ์ฉํ๊ฒ ๋ฉ๋๋ค.
You can get even more specific in the Template Hierarchy by providing a file called, for instance, category-6.php -- this file will be used rather than category.php when generating the page for the category whose ID number is 6. (You can find category ID numbers in Manage > Categories if you are logged in as the site administrator in WordPress version 2.3 and below. In WordPress 2.5 the ID column was removed from the Admin panels. You can locate the category id by clicking 'Edit Category' and looking on the URL address bar for the cat_ID value. It will look '...categories.php?action=edit&cat_ID=3' where '3' is the category id). For a more detailed look at how this process works, see Category Templates.
If your Theme needs to have even more control over which Template files are used than what is provided in the Template Hierarchy, you can use Conditional Tags. The Conditional Tag basically checks to see if some particular condition is true, within the WordPress Loop, and then you can load a particular template, or put some particular text on the screen, based on that condition.
For example, to generate a distinctive stylesheet in a post only found within a specific category, the code might look like this:
<?php
if ( is_category( '9' ) ) {
get_template_part( 'single2' ); // looking for posts in category with ID of '9'
} else {
get_template_part( 'single1' ); // put this on every other category post
}
?>
Or, using a query, it might look like this:
<?php
$post = $wp_query->post;
if ( in_category( '9' ) ) {
get_template_part( 'single2' );
} else {
get_template_part( 'single1' );
}
?>
In either case, this example code will cause different templates to be used depending on the category of the particular post being displayed. Query conditions are not limited to categories, however, see the Conditional Tags article to look at all the options.
It is possible to use the WordPress plugin system to define additional templates that are shown based on your own custom criteria. This advanced feature can be accomplished using the template_redirect action hook. More information about creating plugins can be found in the Plugin API reference.
To load another template (other than header, sidebar, footer, which have predefined included commands like get_header()) into a template, you can use get_template_part(). This makes it easy for a Theme to reuse sections of code.
When referencing other files within the same Theme, avoid hard-coded URIs and file paths. Instead reference the URIs and file paths with bloginfo(): see Referencing Files From a Template.
Note that URIs that are used in the stylesheet are relative to the stylesheet, not the page that references the stylesheet. For example, if you include an images/ directory in your Theme, you need only specify this relative directory in the CSS, like so:
h1 {
background-image: url(images/my-background.jpg);
}
ํ ๋ง๋ฅผ ๊ฐ๋ฐํ ๋, it's good to keep in mind that your Theme should be set up so that it can work well with any WordPress plugins users might decide to install. Plugins add functionality to WordPress via "Action Hooks" (see Plugin API for more information).
Most Action Hooks are within the core PHP code of WordPress, so your Theme does not have to have any special tags for them to work. But a few Action Hooks do need to be present in your Theme, in order for Plugins to display information directly in your header, footer, sidebar, or in the page body. Here is a list of the special Action Hook Template Tags you need to include:
์ค์ ์ฌ์ฉ์ ์๋ฅผ ๋ณด๋ฉด, ์ด๋ฌํ ํ๋ฌ๊ทธ์ธ์ด ๊ธฐ๋ณธ ํ ๋ง์ ํ ํ๋ฆฟ์ ํ๋ฌ๊ทธ์ธ hooks ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
You should escape dynamically generated content in your Theme, especially content that is output in HTML attributes. As noted in ์๋ํ๋ ์ค ์ฝ๋ฉ ํ์ค, text that goes into attributes should be run through esc_attr so that single or double quotes do not end the attribute value and invalidate the XHTML and cause a security issue. Common places to check are title, alt, and value attributes.
In a few cases there might already be a template tag for common cases where safe output is needed. One such case involves the "title" attribute when used with the_title() for post and page titles. To avoid a security vulnerability, use the_title_attribute() instead. Here's an example of correct escaping for the title attribute in a post title link when using translatable text:
<?php echo esc_attr( sprintf( __( 'Permanent Link to %s', 'theme-name' ), the_title_attribute( 'echo=0' ) ) ); ?>
Replace deprecated escape calls with the correct calls: wp_specialchars, htmlspecialchar with esc_html, clean_url with esc_url, and attribute_escape with esc_attr. See Data_Validation for more.
To ensure smooth transition for language localization, use the gettext functions for wrapping all translatable text within the template files. This makes it easier for the translation files to hook in and translate the titles into the site's language. See more at WordPress_Localization and i18n for WordPress Developers.
๋ณธ๋ฌธ, ํฌ์คํธ ๋ฐ ๋๊ธ ์์์ ์๋ํ๋ ์ค์์ ์์ฑ๋ ํด๋์ค ์์ฑ์ ์ถ๊ฐํ๋ ค๋ฉด ๋ค์ ํ ํ๋ฆฟ ํ๊ทธ๋ฅผ ๊ตฌํํฉ๋๋ค. ๊ฒ์๋ฌผ ํด๋์ค์ ๋ด์ฉ์ ๋ฃจํ ๋ด์ ์์์๋ง ์ ์ฉ๋ฉ๋๋ค.
ํ ๋ง๋ฅผ ๊ฐ๋ฐํ ๋, ๋ค์๊ณผ ๊ฐ์ ํ ํ๋ฆฟ ํ์ผ ํ์ค์ ์งํค๊ณ ์๋์ง ํ์ธํ์ญ์์ค.
๋ค์์ ์ฌ๋ฐ๋ฅธ ํ์์ HTML5 ํธํ ํค๋ ์์ญ์ ์ ์ ๋๋ค :
<!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <title><?php wp_title(); ?> <?php bloginfo( 'name' ); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?> <?php wp_head(); ?> </head>
<?php wp_footer(); ?> </body> </html>
<h2><?php printf( __( 'Search Results for: %s' ), '<span>' . get_search_query() . '</span>'); ?></h2>
<script type="text/javascript"> /* <![CDATA[ */ // content of your Javascript goes here /* ]]> */ </script>
ํ ๋ง์ ๋ํ ์คํฌ๋ฆฐ์ท์ ๋ง๋ญ๋๋ค. ์คํฌ๋ฆฐ์ท์ screenshot.png ๋ผ๊ณ ํด์ผ ํ๊ณ , ์ต์์ ๋๋ ํ ๋ฆฌ์ ๋ฐฐ์นํด์ผํฉ๋๋ค. ์คํฌ๋ฆฐ์ท์ ์ ํํ ํ ๋ง ๋์์ธ์ ํ์ํด์ผ ํ๋ฉฐ PNG, JPEG ๋๋ GIF ํ์์ผ๋ก ์ ์ฅํ ์ ์์ต๋๋ค. ๊ถ์ฅํ๋ ์ด๋ฏธ์ง ํฌ๊ธฐ๋ 300x225 ์ ๋๋ค.
ํ ๋ง ์ ํ ์ต์ ํ์ด์ง๋ฅผ ํฌํจํ ์ ์์ต๋๋ค. ์์ ์ฝ๋๋, ์๋ํ๋ ์ค ํ ๋ง ์ต์ ํ์ด์ง๋ฅผ ์ฐธ์กฐํ์ธ์.
์ต์ ํ์ด์ง๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ, ์ฌ์ฉ์๊ฐ ์ค์ ๋ก ์ต์ ํจ๋์ ์ฌ์ฉํ ์ ์๊ฒ ํ ๋ง๋ฅผ ์ ํํ์ง ์๋ ํ, ์ต์ ํจ๋ ๋์ switch_themes ์ edit_theme_options ๊ธฐ๋ฅ์ ์ฌ์ฉํฉ๋๋ค. ์๋ํ๋ ์ค ์์ฒด์ ๋ฉ๋ด, ๋ฐฐ๊ฒฝ, ํค๋, ์์ ฏ ๋ฑ๋ฑ์ ์ํด edit_theme_options ๊ธฐ๋ฅ์ ์ฌ์ฉํฉ๋๋ค. ์ญํ ๋ฐ ๊ธฐ๋ฅ ์ถ๊ฐ ๊ทธ๋ฆฌ๊ณ ๊ด๋ฆฌ์ ๋ฉ๋ด์์ ์ถ๊ฐ๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
๋คํธ์ํฌ ๋ชจ๋์ ํ ๋ง ์ต์ ์ ๋ํ ๋ฉ๋ชจ :
๋น์ ์ ํ ๋ง ์ ์ด๋์๋ edit_themes ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ, ๊ทธ๋ฆฌ๊ณ ํ ๋ง๊ฐ ๋คํธ์ํฌ์ ์ฐ๊ฒฐ๋์ด ์๋ํ๋ ์ค ์ค์น(์ด์ ์๋ ํ๋ ์ค MU) ๊ธฐ๋ฅ ์๋์ ์คํ๋๋ค๋ฉด, ํ ๋ง ์ต์ ํ์ด์ง์ ์ ๊ทผํ์ฌ ์ฌ์ฉํ๋ edit_themes ๊ธฐ๋ฅ์ ์ต์ ๋ฉ๋ด๋ฅผ ๋ณผ๋ ๋คํธ์ํฌ์ ์ฐ๊ฒฐ๋ ์ฌ์ดํธ ๊ด๋ฆฌ์๊ฐ ์์ ํ์ง ์๋๋ก ์ฃผ์ํ์ญ์์ค. ๋์ edit_theme_options ๋ฅผ ์ฌ์ฉํฉ๋๋ค.