This is the website i´m working on: http://canal.es/wordpress/
The problem I have is that, if you go, to “Pasteleria dulce” (which is a category.php file) it shows a left sidebar with the active title of the category, it shows a post on the center and it shows below the image a list of the post of the same category.
I haven´t find a solution to highlight the post title that opens automatically when I enter to the category. This is the code i´m using on the category.php file:
<!-- 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>
How can I make active the current post title that appears when I open the category page?
Try to use this solution: