我试图将查询菜单的一页标记为活动-->(我找到了答案)
function render_main_menu(){
$args = array(
\'post_type\' => \'a_cpt\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'your_tax\',
\'field\' => \'slug\',
\'terms\' => \'your_term\',
),
),
);
$loop = new WP_Query($args);
$thetitle = strtolower(get_the_title());
$thetitle = preg_replace("/[\\s]/", "-", $thetitle);
while($loop->have_posts()) : $loop->the_post();
//here the solution-->
//marks as bold only the current post -->
if ( $thetitle == current_post_slug() ) : ?>
<div style="font-weight: bold;">
<?php else : ?>
<div>
<?php endif;
echo \'<a href="\'.get_permalink().\'">\'.get_the_title().\'</a>\'; ?>
</div>
<?php endwhile;
wp_reset_postdata();
add_action( \'genesis_after_header\', \'render_main_menu\', 15 );
function current_post_slug() {
global $post;
$post_slug=$post->post_name;
if ( $post_slug && ! is_wp_error( $terms ) ) {
return $post_slug;
}
}
谢谢