0
從自定義帖子類型「服務」創建菜單,我想突出顯示正在顯示的頁面。我怎麼做?在Wordpress中突出顯示當前頁面/內容類型
一切都在代碼工作如下(下面這段代碼),除了這部分,我需要的幫助:
if (current_page_on == this_menu_item_from_loop) {
// This is the current page - highlight the <li>
}
...
<?php
$type = 'services';
$args=array('post_type' => $type);
$my_query = null;
$my_query = new WP_Query($args);
if($my_query->have_posts()) {
while ($my_query->have_posts()) : $my_query->the_post();
if (current_page_on == this_menu_item_from_loop) {
// This is the current page - highlight the <li>
}
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
}
wp_reset_query();
?>