단일 제품에 대한 사용자 정의 탭을 만들었으며 해당 탭의 콘텐츠 역할을 할 특정 페이지를 지정하는 방법이 있는지 아래 코드로 알고 싶습니다.
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'Seller Disclosure', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
echo '<h2>Coming Soon</h2>';
}
다음과 같이 정의 된 게시물 ID (페이지)에 대해 클래식 WordPress 게시물 콘텐츠를 호출 할 수 있습니다.
//Add a new tab in single product pages
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
$tabs['test_tab'] = array(
'title' => __( 'Seller Disclosure', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
// The tab content (with the page content)
function woo_new_product_tab_content() {
// ==> ==> ==> ==> ==> ==> ==> Replace the ID HERE by your page ID
$page_id = 324;
$page_post_object = get_post( $page_id );
// Get the page content
$page_content = $page_post_object->post_content;
// (optionally Get the page title
$page_title = $page_post_object->post_title;
// The title (Or the page title)
echo '<h2>Coming Soon</h2>'; // Or: echo '<h2>' . $page_title . '</h2>';
// The page content
echo '<div class="page-content-container">' . $page_content . '</div>';
}
코드는 활성 자식 테마 (또는 테마)의 모든 PHP 파일 또는 플러그인 PHP 파일에 저장됩니다.
이 코드는 테스트되고 작동합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다