๐ŸŽฌ WordPress์—์„œ YouTube Shorts๋ฅผ ์˜ˆ์˜๊ฒŒ ๋ณด์—ฌ์ฃผ๋Š” ๋ฐฉ๋ฒ• (9:16 ๋น„์œจ ์‚ฝ์ž…)

WP์—์„œ ์œ ํŠœ๋ธŒ ์‡ผ์ธ  ์˜ˆ์˜๊ฒŒ ๋„ฃ๋Š” ๋ฒ•

๋ณดํ†ต ์›Œ๋“œํ”„๋ ˆ์Šค์—์„œ๋Š” /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>

์ธ๋„ค์ผ + ๋งํฌํ˜• ๊ฐค๋Ÿฌ๋ฆฌ, ์ž๋™ ์ถ”์ถœ ๋“ฑ์„ ํฌํ•จํ•œ ๋” ๋ฐœ์ „๋œ ๊ตฌ์„ฑ๋„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ํ•„์š”ํ•˜์‹œ๋ฉด ๋Œ“๊ธ€๋กœ ์•Œ๋ ค์ฃผ์„ธ์š”!

You may also like...

Leave a Reply

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