반응형
WooCommerce 검색 결과 템플릿
저는 WooCommerce WordPress 사이트에서 일하고 있습니다.제품에 대한 WooCommerce 검색 기능을 추가했습니다.그러나 메인 숍 페이지와 검색 결과 페이지 모두 동일한 템플릿 archive-product.php를 가지고 있습니다.하지만 두 페이지 모두 별도의 디자인을 원합니다.내가 어떻게 그럴 수 있을까?
@arun이 코멘트에서 말한 것처럼 archive-product.php를 복사하여 테마 내의 woocommerce 폴더에 붙여넣습니다(이 폴더가 없는 경우 작성하십시오).
파일을 열고 php if 문을 사용하여 파일 내의 콘텐츠를 분할합니다.
if ( is_search() ) {
//put your search results markup here (you can copy some code from archive-product.php file and also from content-product.php to create a standard markup
} else {
// here goes the content that is already in that file (archive-product.php)
}
이 코드 행은 항상 파일 맨 위에 있어야 합니다.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@Capital Themes 답변에 따라 함수를 반전하여 검색 이외의 폼 카테고리에 코드를 추가할 수 있습니다.
<?php if (! is_search() ) {
//Added code for non search form
} else {
// if want something only for search
} ?>
woocommerce/directore에서 product-searchform.directore 파일을 사용해야 합니다.
검색 페이지를 woocomerce/woocomerce/global directore의 루프 파일로 커스터마이즈합니다.
그 후 is_search() 메서드를 사용하여 검색 페이지에 있는지 여부를 확인할 수 있습니다.
언급URL : https://stackoverflow.com/questions/23490317/woocommerce-search-result-template
반응형
'programing' 카테고리의 다른 글
프로젝트 웹 사이트를 프로그래밍하기 위한 단순 클린 CMS (0) | 2023.03.22 |
---|---|
연락처 양식 7 기본 옵션 메일에서 선택한 값으로 인쇄 (0) | 2023.03.22 |
Elastic Search를 사용하여 중첩된 객체를 검색하는 방법 (0) | 2023.03.22 |
SQL*Plus에서 시작/종료를 사용하여 Oracle 쿼리를 실행하는 방법 (0) | 2023.03.22 |
Oracle SQL : where 절의 타임스탬프 (0) | 2023.03.22 |