<ul>
<li <?php if (is_page('about-us') or wp_get_post_parent_id(0)==14) echo 'class="current-menu-item"'?>><a href="<?php echo site_url('/about-us') ?>">About Us</a></li>
<li><a href="#">Programs</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Campuses</a></li>
<li <?php if (get_post_type() == 'post') echo 'class="current-menu-item"'?>><a href="<?php echo site_url('/blog'); ?>">Blog</a></li>
</ul>
위에서 워드프레스 메뉴 블로그 부분을 설정하였습니다.
우선 site_url('/blog')를 통해 블로그로 이동할 수 있는 링크를 보이도록 하였습니다.
또한 php코드와 css를 사용하여 블로그와 관련된 글에 있을 때 블로그가 노랑색으로 표시되도록 하였습니다.
<?php if (get_post_type() == 'post') echo 'class="current-menu-item"'?>
포스트 종류가 '포스트' 즉 블로그와 관련된 부분이라면 현지 "current-meu-item"이 노랑색으로 표시되도록 한다는 의미입니다.
아래와 같이 노랑색으로 표시가 되었습니다.

'코딩' 카테고리의 다른 글
홈페이지에 Custom Post Type 표시하기 (feat. Events) (0) | 2022.12.17 |
---|---|
워드프레스 custom post type 만들기 (0) | 2022.12.17 |
워드프레스 Custom Query 사용하여 홈페이지 꾸미기 (0) | 2022.12.16 |
Archive 하는 방법 (0) | 2022.12.16 |
워드프레스 블로그 포스트 페이지 꾸미기 (0) | 2022.12.16 |