• Hello,

    I’m happy with this bit: I’ve made a mini nav bar on ‘archive.php’ –?it highlights the current category name (and has a headline above with the same category name). Let’s call it “Category 1”. When I click any category on the nav bar (eg. Category 1, 2, 3 etc.) it highlights the category chosen (and headlline), and lists all the posts within it, below. All good.

    Not so happy with this bit: However, when I click an individual post within any of those categories, and go through to the post page itself (single.php) –?the post no longer highlights that individual category name, eg. “Category 1” on the nav bar (to which the post belongs). All it displays is the title category which in this case I’ll call “Our Blog” –?and also the nav bar just below is not highlighted.

    So –?when I click a post and load single.php I want the the main category related to the post (e.g. “Category 1”) to be both the title AND highlighted in the mini nav bar ONLY.

    I’ve tried amending the functions.php, which enables me to highlight the category name in the mini nav bar, but it also highlights “Our Blog” in this same mini nav bar, and the title is also “Our Blog” –?I want both of these to be “Category 1” –?and not highlight “Our Blog” at all.

    So to note: each post has 2 categories selected – always “Our Blog” and then “Category 1, 2, 3, 4” etc. However I don’t want “Our Blog” to be highlighted as I said above –?when on the post itself.

    Hope that makes some kind of sense! I can post any code if need be,

Viewing 1 replies (of 1 total)
  • Thread Starter lazystuff

    (@lazystuff)

    <ul id="projectNav" class="clearfix">
    <ul id="categories">
    <li class="skillList">
    <ul class="post-categories">
    <?php
        // Get the ID of a given category
        $category_id = get_cat_ID( 'Category Name' );
    
        // Get the URL of this category
        $category_link = get_category_link( $category_id );
    
        $category = get_the_category( $post_id); 
    
    ?>
    <?php get_category_link( $category_id ); ?><?php
        $args = array(
    	'show_option_all'    => '',
    	'orderby'            => 'order',
    	'order'              => '',
    	'style'              => 'list',
    	'show_count'         => 0,
    	'hide_empty'         => 1,
    	'use_desc_for_title' => 0,
    	'child_of'           => 0,
    	'feed'               => '',
    	'feed_type'          => '',
    	'feed_image'         => '',
    	'exclude'            => '',
    	'exclude_tree'       => '',
    	'include'            => '47,19,16,61,59,60,58,65',
    	'hierarchical'       => 1,
    	'title_li'           => __( '' ),
    	'show_option_none'   => __( '' ),
    	'number'             => null,
    	'echo'               => 1,
    	'depth'              => -1,
    	'current_category'   => 0,
    	'pad_counts'         => 0,
    	'taxonomy'           => 'category',
    	'walker'             => null
        );
        wp_list_categories( $args );
    ?>

    This is what is in single.php

Viewing 1 replies (of 1 total)
  • The topic ‘single.php display category in mini nav bar’ is closed to new replies.