Home 게시판 커뮤니티 Q&A taxonomy용 single.php 만드는법

1개 답변, 2 voices Last updated by Avatar of oksambarioksambari 6 years, 11 months 전
  • Avatar of BillieJoeBillieJoe
    Participant
    @kwonohhwan
    #53149

    taxonomy용 single.php을 어떻게 생성하나요?

    구글링해서

     

    add_filter( ‘single_template’, ‘single_tax_term_template’ );
    function single_tax_term_template( $single_template ) {

    global $post;

    if ( has_term( ”, ‘article’ ) ) {
    $single_template = dirname( __FILE__ ) . ‘/article.php’;
    }

    if ( has_term( ”, ‘news’ ) ) {
    $single_template = dirname( __FILE__ ) . ‘/news.php’;
    }

    return $single_template;
    }

     

    위 코드를 function.php에 추가를 했는데 후에 택소노미용 페이지용 single.php를 만들어서 적용하려는데 감이 잘 안와서 질문 남겨드립니다.

    Avatar of oksambarioksambari
    Participant
    @oksambari
    #53154

    워드프레스의 탬플릿 구조를 이용하시면 접근이 쉬우실 겁니다.

    임의로 구조나 파일을 연결하실 필요가 없이 이미 약속된 방식이 있습니다~

    https://wphierarchy.com/

    Avatar of oksambari
    Publishing Homepage [&] Blogging about WP.
    Wordpress를 워드프레스답게!
2 글 보임 - 1에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.