<span>您的位置:</span><a href="/">首页</a><span> > </span><span><a href="/prodcuts">产品介绍</a></span> </div> </div> <div class="alldivwid clearfix"> <div class="left_nav"> <h2>产 品 分 类</h2> <ul class="clearfix"> <?php /*if(have_posts()): while(have_posts()): the_post(); //$category = get_the_category(); //$name = $category['term_id']; endwhile; endif; */ $pro_menu = dit_get_all_children_pages('147'); foreach ($pro_menu['html'] as $key => $val) { echo '<li>' . $val . '</li>'; } ?> </ul> </div> <div class="right_content"> <?php // 検索结果用 //$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //不能用分页,因为url不能跳转到原网页(添加的page形式有问题) $args = array('s' => $s, 'showposts' => -1); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post();
<div class="alldivwid clearfix"> <div class="left_nav"> <h2>产 品 分 类</h2> <ul class="clearfix"> <?php //wp_list_categories("child_of=14&depth=0&hide_empty=0&title_li="); $name = get_the_title(); } } //获得产品页面id $names = 'products'; //page别名 global $wpdb; $page_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$names}'"); $pro_menu = dit_get_all_children_pages($page_id); foreach ($pro_menu['html'] as $key => $val) { if ($name == $pro_menu['title'][$key]) { echo '<li class="onactive">'; } else { echo '<li>'; } echo $val . '</li>'; } ?> </ul> </div> <div class="right_content"> <?php //获得分类id $all_products = get_category_by_slug('product');