我从自定义帖子类型“服务”创建菜单,我想突出显示我所在的页面。我怎么做?
除了我需要帮助的这部分之外,一切都在下面的代码中(在此代码下方)中工作:
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();
?>