워드프레스 - 특정 위젯 표시
길을 잃었어요.
다이너믹 푸터사이더바가 있다고 칩시다.아직까지는 쉽다.
<footer>
<?php get_sidebar("name") ?>
</footer>
바닥글에 표시합니다.
하지만 우리는 여기 있다.각 위젯을 그리드에 넣습니다.
<footer>
<div style="width: 100px:">
<div style="width: 25%">First widget here</div>
<div style="width: 25%">Second widget here<</div>
<div style="width: 25%">Third widget here<</div>
<div style="width: 25%">Fourth widget here<</div>
</div>
</footer>
따라서 get_sidebar는 모든 위젯을 한 줄로 표시하므로 현재 옵션이 아닙니다.그리고 위젯 자체를 편집하고 싶지 않습니다.
테마에서는 어떻게 하는 거죠?
감사해요.
이 경우 'the_widget' 함수를 사용할 수 있습니다.
<?php the_widget($widget, $instance, $args); ?>
자세한 내용은 Wordpress Codex - The_Widget 참조를 참조하십시오.
이것도 참고 자료입니다 - 기능 참조/동적 사이드바 » WordPress Codex
이 페이지의 방법을 사용하는 경우:
<ul id="sidebar">
<?php if ( !dynamic_sidebar() ) : ?>
<li>{static sidebar item 1}</li>
<li>{static sidebar item 2}</li>
<?php endif; ?>
</ul>
그런 다음 CSS 스타일링을 사용하여 바닥글 전체에 사이드바 위젯을 배치할 수 있습니다.
다음을 포함하도록 편집...
Arras 테마 CSS:
#footer { margin: 20px auto 0; width: 980px; background: #ECEBE6; padding-bottom: 10px; border: 1px solid #CCC; }
#footer .widgetcontainer { padding: 5px 10px; min-width: 150px; }
.no-js #footer .widgetcontainer { height: 190px; }
#footer .widgettitle { background: none; border: none; font-size: 14px; color: #444; padding: 0 0 10px; letter-spacing: -1px; }
#footer .widgetcontent { font-size: 12px; background: none; padding: 0; border: none; }
#footer .footer-message { margin: 0; padding: 10px 15px 0; font-size: 11px; }
#footer .footer-message p { margin: 0 0 0.5em; }
#footer .footer-message .floatright { margin-left: 20px; }
#footer-sidebar { overflow: hidden; margin: 10px 10px 0; padding: 0 0 10px; border-bottom: 1px solid #CCC; }
#footer-sidebar .widgetcontainer { float: left; margin: 0; max-width: 250px; }
#footer-sidebar ul { list-style: none; margin: 0; padding: 0; }
#footer-sidebar li { margin: 0 0 3px; }
바닥글 부호화:
<ul id="footer-sidebar" class="clearfix xoxo">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer') ) : ?>
<li></li>
<?php endif; ?>
</ul>
그런 다음 주제에서 위젯을 페이지 전체에 배치합니다.
또는 다음을 사용할 수도 있습니다.
<?php dynamic_sidebar( 'sidebar-1' ); ?>
특정 위젯을 표시하는 새 플러그인을 확인하십시오.
http://wordpress.org/extend/plugins/widget-instance/에 접속해 주세요.
위젯 옵션 플러그인을 사용하여 모든 페이지 및 디바이스에서 위젯 표시를 제한하거나 제어할 수 있습니다. https://wordpress.org/plugins/widget-options/ 저장소에서 무료로 사용할 수 있습니다.또는 를 사용해 보십시오.widget_display_callback
https://developer.wordpress.org/reference/hooks/widget_display_callback/. 도움이 되었으면 합니다.
function custom_display_callback( $instance, $widget, $args ){
if( is_page() ){
return false;
}
return $instance;
}
add_filter( 'widget_display_callback', 'custom_display_callback', 50, 3 );
언급URL : https://stackoverflow.com/questions/4214830/wordpress-display-specific-widget
'programing' 카테고리의 다른 글
각도 부트스트랩모달:알 수 없는 공급자: $modal인스턴스 프로바이더 (0) | 2023.03.20 |
---|---|
"require(x)"와 "import x"의 차이 (0) | 2023.03.20 |
wordpress admin의 Jquery UI 대화 상자 (0) | 2023.03.15 |
기능적 리액트 컴포넌트에 대해 기능 선언보다 화살표 구문이 선호되는 이유는 무엇입니까? (0) | 2023.03.15 |
테이블 CHARSET이 utf8mb4로, COLATION이 utf8mb4_unicode_520_ci로 설정되어 있는 이유는 무엇입니까? (0) | 2023.03.15 |