후쿠오카현 구루메시에 위치한 작은 홈페이지・웹사이트 제작소

猫壱屋 サイト ホームページ 作成 制作

MEMOMEMO

functions.php에 작성해두면 유용한 코드 (2)

2023-11-14 23:54

/* 포스트 포맷 활성화*/
add_theme_support( 'post-formats', array(
// 배열로 여러 포맷을 지정할 수 있습니다.
'aside', //사이드
'gallery', //갤러리
'image', //이미지
) ) );

/* 관리자 화면에서 포스트 에디터용 스타일 적용*/
add_editor_style(); // 기본적으로 editor-style.css를 불러옵니다. 인수에 자체 파일 경로를 지정할 수도 있습니다.

// 파비콘 설치
function custom_favicon() {
echo '<link rel="shortcut icon" type="image/x-icon" href="' . esc_url(get_template_directory_uri()) . '/image/favicon.ico" />' . "n";
echo '<link rel="apple-touch-icon" sizes="180x180" href="' . esc_url(get_template_directory_uri()) . '/image/apple-touch-icon.png">' . "n";
echo '<link rel="icon" type="image/png" sizes="192x192" href="' . esc_url(get_template_directory_uri()) . '/image/android-chrome-192x192.png">' . "n";
echo '<meta name="apple-mobile-web-app-title" content="Your App Title">' . "n";
}
add_action('wp_head', 'custom_favicon'); .

// 절대 경로 생략 //
function edit_menu_link( $atts ) {
if( !is_front_page() ){
$href = $atts['href'];
if( substr($href, 0, 1) === '#' ) {
$atts['href'] = home_. url('/'). $href;
}
} }
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'edit_menu_link', 10 );

// 임의의 식별자, 설명 //
function add_register_nav_menu() {
register_nav_menu( 'main-menu', 'main-menu' );
}
add_action( 'after_setup_theme', 'add_ register_nav_menu' );

<< 목록으로 돌아가기