0
這是工作在網站上i'm:http://canal.es/wordpress/高亮(活動)菜單中的文章標題
我的是,如果你去,爲「Pasteleria杜爾塞」的問題(這是一個category.php文件),它顯示了一個左側邊欄,其中顯示了該類別的活動標題,它在中心顯示了一個帖子,並在圖片下方顯示了同一類別帖子的列表。
我沒有找到解決方案來突出顯示當我進入該類別時自動打開的帖子標題。這是我在category.php文件上使用的代碼:
<!-- Highlight menu from current category -->
<?php
if (is_category()) {
$this_category = get_category($cat);
}
if($this_category->category_parent)
$this_category = wp_list_categories('orderby=id&title_li=&child_of='.$this_category->category_parent."&echo=0"); else
$this_category = wp_list_categories('orderby=id&title_li=&child_of='.$this_category->cat_ID."&echo=0");
if ($this_category) { ?>
<ul class="sub-menu">
<?php echo $this_category; ?>
</ul>
<?php } ?>
<div class="producto_column">
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<div class="producto_image">
<img src="<?php the_field('imagen_producto'); ?>" alt=""/>
</div>
<div class="share_item">
<a class="minimal" id="premium">
<img src="<?php bloginfo('template_directory') ?>/images/share.png" alt="share">
</a>
<a class="maillink" href="http://canal.local/?page_id=220">
<img src="<?php bloginfo('template_directory') ?>/images/email.png" alt="email">
</a>
</div>
<?php get_template_part('content', get_post_format()); ?>
<?php endwhile; ?>
<!-- Post list from current category -->
<ul id="submenu_productos" class="clearfix">
<?php
$IDOutsideLoop = $post->ID;
while(have_posts()) {
the_post();
foreach((get_the_category()) as $category)
$my_query = new WP_Query('category_name=' . $category->category_nicename . '&orderby=title&order=asc&showposts=100');
if($my_query) {
while ($my_query->have_posts()) {
$my_query->the_post(); ?>
<li<?php print (is_single() && $IDOutsideLoop == $post->ID) ? ' class="test"' : ''; ?>>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> |
</li>
<?php
}
}
}
?>
</ul>
我該如何激活當前打開類別頁面時顯示的帖子標題?
它doesn't似乎工作。不管怎樣,謝謝你。它看起來像這個目標的路徑,這是目前的類別路徑,而不是郵件的路徑... –
嘗試新的!這可能是你的 – RDK
hehe不,現在這個隨機顯示所有類別的帖子...看看網站,它不會突出顯示任何東西 –