do_shortcode()
do_shortcode( string $content, bool $ignore_html = false );
echo do_shortcode('[name_of_shortcode]');
숏코드 사용
get_template_part()
get_template_part( string $slug, string $name = null, array $args = array() );
get_template_part( 'template-parts/content', 'page' );
테마 폴더의 서브 디렉토리에서 템플릿 파일 로드
get_the_post_thumbnail()
get_the_post_thumbnail( int|WP_Post $post = null, string|int[] $size = 'post-thumbnail', string|array $attr = '' );
get_the_post_thumbnail( $post_id );
get_the_post_thumbnail( $post_id, 'thumbnail' ); // Thumbnail (Note: different to Post Thumbnail)
get_the_post_thumbnail( $post_id, 'medium' ); // Medium resolution
get_the_post_thumbnail( $post_id, 'large' ); // Large resolution
get_the_post_thumbnail( $post_id, 'full' ); // Original resolution
get_the_post_thumbnail( $post_id, array( 100, 100) ); // Other resolutions
이미지 url(img 태그로 반환)
get_template_directory_uri()
get_template_directory_uri();
echo get_template_directory_uri();
// //192.168.1.198:4100/wp-content/themes/moim-wp
활성화 된 테마의 디텍토리 uri 검색
uri : Uniform Resource Identifier
wp_enqueue_style()
wp_enqueue_style( string $handle, string $src = '', string[] $deps = array(), string|bool|null $ver = false, string $media = 'all' )
wp_enqueue_style('zeein-style-new', get_template_directory_uri() . '/style-append.css', array(), _S_VERSION);
테마에 스타일 파일(css) 추가 사용
wp_enqueue_script()
wp_enqueue_script( string $handle, string $src = '', string[] $deps = array(), string|bool|null $ver = false, bool $in_footer = false )
wp_enqueue_script('zeein-custom', get_template_directory_uri() . '/js/custom.js', array(), _S_VERSION, true);
테마에 스크립트 파일(js) 추가 사용
get_posts()
get_posts( array $args = null )
$posts = get_posts(array(
'post_type' => 'portfolio',
'post_status' => 'publish',
'post_per_page' => -1,
));
원하는 post type의 게시물 배열값 반환
get_field()
get_field($selector, [$post_id], [$format_value]);
$link = get_field('link', $post->ID)
ACF 전용 함수로 필드의 값을 반환
SITE 1do_shortcode
SITE 2get_template_part
SITE 3get_the_post_thumbnail
SITE 4get_template_directory_uri
SITE 5wp_enqueue_style
SITE 6wp_enqueue_script
SITE 7get_posts
SITE 8get_field