하단 메뉴를 위젯에서 수정할 수 있도록 위젯 기능을 활성화 하고 수정하는 방법을 알아보로고 하겠습니다.
현재 테마는 custom theme이기 때문에 외모 하위 메뉴에 위젯이라는 메뉴가 활성화 되어 있지 않습니다.
이전에 특성화 이미지가 노출되지 않듯이 이 부분도 funcstions.php 파일에서 위젯을 테마에서 사용하겠다고 지정을 해야만 사용할 수 있습니다.
functions.php
function zeein_yellow_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Footer', 'zeein-yellow' ), 'id' => 'widget-footer', 'description' => esc_html__( 'Add widgets here.', 'zeein-yellow' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'zeein_yellow_widgets_init' );
위와같이 위젯을 추가 해주고 사이드바를 등록 해주면 관리자 메뉴에서 외모 > 위젯 이 활성화 되는 것은 확인하실 수 있습니다.
footer.php
<div id="footer"> <?php if ( is_active_sidebar('widget-footer') ) { dynamic_sidebar('widget-footer'); } else { echo 'Copyright (c) 2017 ZEEIN.'; } ?> </div>
functions.php 파일에서 등록한 widget-footer가 활성화 되어 있으면 내용을 화면에 보여주고 그렇지 않은 경우 기본 문구를 출력하도록 내용을 추가 후 저장합니다.
main.css
/* footer */ #footer section { padding: 2rem 0; } #footer section p { font-size: 0.75rem; font-family: 'Open Sans', Arial, Helvetica, sans-serif; letter-spacing: normal; text-align: center; margin: 0.4rem 0; } #footer section p a { color: #1D1D1D; }