php - WordPress add class="current_page" to corresponding page when listing child pages
one text
How would I add class="current_page"
to the li
of this code below so that I can style the link to be bold with CSS. The code below lists the WordPress child/sibling pages of a parent and I want to apply class="current_page"
to the specific child/sibling page that corresponds to the current page.
Thanks
<?php if($post->post_parent): ?>
<?php $children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0'); ?>
<?php else: ?>
<?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'); ?>
<?php endif; ?>
<?php if ($children) { ?>
<ul class="subpage-list">
<?php echo $children; ?>
</ul>
<?php } ?>
Source