【发布时间】:2016-03-22 11:47:01
【问题描述】:
我需要将“活动”或“当前菜单项”类添加到自定义子页面菜单。我已经尝试了下面的代码,但它似乎不起作用。
我浏览了谷歌,但找不到任何可行的方法!
<?php
$childpages = query_posts('orderby=menu_order&order=asc&post_type=page&post_parent=35&posts_per_page=300');
if ($childpages)
{
// Display the children content
foreach ($childpages as $post)
{
setup_postdata($post)
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="mezzanine-sub-title <?php echo!empty($_GET['page_id']) && $_GET['page_id'] == $post->ID ? "active" : NULL ?>">
<span><?php the_title(); ?></span>
<a>
<?php
global $post;
$src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(5600, 1000), false, '');
?>
<div class="mezzanine-sub-image" style="background: url(<?php echo $src[0]; ?> );border:<?php the_field('border'); ?>;">
</div>
</a>
</a>
<?php
}
}
?>
提前致谢
【问题讨论】: