get_header() | 헤더 호출

|

개요

활성화된 테마 폴더에 있는 header.php을 불러옵니다. 다른 헤더 파일을 만들어서 필요할 때마다 호출할 수도 있습니다

코드

<?php get_header() ?>

테마 폴더에 있는 header.php 파일을 불러옵니다

<?php get_header('rdg') ?>

테마 폴더에 있는 header-rdg.php 파일을 불러옵니다

header.php

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<!-- header -->

<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta property="article:published_time" content="<?php the_time('c'); ?>">
    <meta property="article:modified_time" content="<?php echo get_the_modified_time('c'); ?>">
    <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
    <link rel="profile" href="https://gmpg.org/xfn/11" />
    <?php wp_head(); ?>
</head>

<body <?php body_class() ?>>

몇년간 고민하며 만든 자료입니다. <body> 태그가 마무리가 되어있지 않기 때문에 footer.php 에 </body> 태그로 닫아야 함을 기억해야 합니다.

<meta property="og:image" content="<?php echo has_post_thumbnail() ?  the_post_thumbnail_url() : '이미지 URL'; ?>" />

SNS 공유 시 보이는 이미지를 선택할 수 있습니다. has_post_thumbnail() 함수를 사용하며, 특성이미지가 없을 때에는 대체로 이미지 URL 를 보여줍니다.

혹시나 이미지 URL이 없는 경우 공백으로 두면 됩니다. 이 때 아무것도 표시되지 않습니다.

같이 사용하는 함수

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

클릭하여 복사