๐ฌ WordPress์์ YouTube Shorts๋ฅผ ์์๊ฒ ๋ณด์ฌ์ฃผ๋ ๋ฐฉ๋ฒ (9:16 ๋น์จ ์ฝ์ )

๋ณดํต ์๋ํ๋ ์ค์์๋ /youtube
๋ธ๋ก์ด๋ ์๋ ์๋ฒ ๋๋ฅผ ํตํด ์ผ๋ฐ YouTube ์์์ ์ฝ๊ฒ ๋ฃ์ ์ ์์ต๋๋ค. ํ์ง๋ง YouTube Shorts์ ๊ฒฝ์ฐ, 9:16 ์ธ๋ก ๋น์จ์ด ์ ๋๋ก ๋ง์ง ์๊ณ ํ๋ ์์ ์ฌ๋ฐฑ์ด ๋ง์ด ์๊ธฐ๊ฑฐ๋ ์ธ๋ค์ผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์กฐ์ฐจ ๋์ง ์๋ ๋ฌธ์ ๊ฐ ์์ฃ .
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ์๋์ฒ๋ผ ์ง์ HTML ๋๋ ์์ฝ๋(shortcode)๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ์์ด ๊ฐ์ฅ ๊น๋ํฉ๋๋ค.
โ ๋ฐฉ๋ฒ 1: ์ง์ HTML๋ก ์ฝ์ ํ๊ธฐ
ํธ์ง๊ธฐ์์ โ์ปค์คํ HTMLโ ๋ธ๋ก์ ์ถ๊ฐํ ๋ค, ์๋ ์ฝ๋๋ฅผ ๋ถ์ฌ๋ฃ์ผ์ธ์.
<!-- ์ ํ๋ธ ์ผ์ธ ์ ์ฉ ์๋ฒ ๋ (9:16 ๋น์จ) -->
<div style="aspect-ratio: 9 / 16; max-width: 466px; margin: 2rem auto;">
<iframe
src="https://www.youtube.com/embed/XZ2DFlT2lZ0?playsinline=1&modestbranding=1"
style="width: 100%; height: 100%; border: none;"
allowfullscreen
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share">
</iframe>
</div>
์ ์ฝ๋์์ XZ2DFlT2lZ0
๋ถ๋ถ๋ง ๋ณธ์ธ์ Shorts ID๋ก ๋ฐ๊พธ๋ฉด ๋ฉ๋๋ค. (URL ์ค https://www.youtube.com/embed/
๋ค์ ๋ถ๋ถ)
โ ๋ฐฉ๋ฒ 2: functions.php์ ์์ฝ๋ ๋ฑ๋กํ๊ธฐ
์๋ ์ฝ๋๋ฅผ functions.php
์ ์ถ๊ฐํ๋ฉด [
shorts id="..."]
ํ์์ผ๋ก ์์ฝ๊ฒ ์ธ ์ ์์ต๋๋ค.
// ์ ํ๋ธ ์ผ์ธ ์ ์ฉ ์์ฝ๋
function render_youtube_shorts($atts) {
$atts = shortcode_atts([
'id' => '',
], $atts);
if (!$atts['id']) return '';
return '<div style="aspect-ratio: 9 / 16; max-width: 466px; margin: 2rem auto;">
<iframe
src="https://www.youtube.com/embed/' . esc_attr($atts['id']) . '?playsinline=1&modestbranding=1"
style="width: 100%; height: 100%; border: none;"
allowfullscreen
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share">
</iframe>
</div>';
}
add_shortcode('shorts', 'render_youtube_shorts');
์ด์ ๋ณธ๋ฌธ์์๋ ์๋์ฒ๋ผ ๊ฐ๋จํ๊ฒ ์ฐ๋ฉด ๋!
[shorts id="..."]
๐ฑ ๋ฐ์ํ๋ ์ง์๋ฉ๋๋ค
์ด ์ฝ๋๋ ๋ชจ๋ฐ์ผ ํ๋ฉด์์๋ 9:16 ๋น์จ์ ์ ์งํ๋ฉด์ ๊น๋ํ๊ฒ ๋ณด์ ๋๋ค.
์ ๋ธ๋ก๊ทธ์ ์ฌ์ฉ๋ ์๋ฅผ ์ดํด๋ณด๋ฉด, ์ด ํฌ์คํธ์์๋ ๋จ์ผ Shorts ๋ทฐ์ด๋ฅผ ์ ์ค์์ ๋ฐฐ์นํ์ฌ ๊น๋ํ ํ๋ ์ ํ ์ด์ ์ ๋ณด์ฌ์ฃผ๊ณ ์๊ณ ,
์ด ๊ธ์์๋ ํ ์ค์ 3๊ฐ์ Shorts๋ฅผ ๊ทธ๋ฆฌ๋๋ก ๋ฐฐ์ดํ์ฌ ๋ ๋ค์ฑ๋ก์ด ๊ตฌ์ฑ์ ํ์ฉํ์ต๋๋ค.
<div class="shorts-grid">
<div class="shorts-item">
<iframe src="https://www.youtube.com/embed/NbJ3m0Tpsvo?playsinline=1&modestbranding=1"
allowfullscreen
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
style="width: 100%; height: 100%; border: none;">
</iframe>
</div>
<div class="shorts-item">
<iframe src="https://www.youtube.com/embed/MezpyfOh1IE?playsinline=1&modestbranding=1"
allowfullscreen
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
style="width: 100%; height: 100%; border: none;">
</iframe>
</div>
<div class="shorts-item">
<iframe src="https://www.youtube.com/embed/8Cf5X6IU0Zw?playsinline=1&modestbranding=1"
allowfullscreen
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
style="width: 100%; height: 100%; border: none;">
</iframe>
</div>
<!-- ๋ ์ถ๊ฐ ๊ฐ๋ฅ -->
</div>
<style>
.shorts-grid {
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: center;
}
.shorts-grid .shorts-item {
flex: 0 0 calc(33.33% - 1rem);
max-width: 300px;
aspect-ratio: 9 / 16;
}
@media (max-width: 768px) {
.shorts-grid .shorts-item {
flex: 0 0 calc(50% - 1rem);
}
}
@media (max-width: 480px) {
.shorts-grid .shorts-item {
flex: 0 0 100%;
}
}
</style>
์ธ๋ค์ผ + ๋งํฌํ ๊ฐค๋ฌ๋ฆฌ, ์๋ ์ถ์ถ ๋ฑ์ ํฌํจํ ๋ ๋ฐ์ ๋ ๊ตฌ์ฑ๋ ๊ฐ๋ฅํฉ๋๋ค. ํ์ํ์๋ฉด ๋๊ธ๋ก ์๋ ค์ฃผ์ธ์!