• Resolved pg73

    (@pg73)


    Hi,

    Just hoping someone would be kind enough to help with this issue I’m having. I’ll try to explain it as simply as possible.

    I have added the code below to create my main navigation:

    <div id="main-nav">
    	<ul>
    		<li><a href="<?php echo get_option('home'); ?>/">Home</a></li>
    		<?php wp_list_pages('title_li=&depth=1&exclude='); ?>
    	</ul>
    </div>

    It creates a list that includes a ‘home’ link (which takes me to ‘domain.com’ and then all of my ‘page links’.

    The CSS works fine on them all (‘home’ and the ‘page links’) in as much as they change colour as I hover over them and when I click on a any of the ‘page links’, I’m taken to that page (domain.com/page-name) and the ‘page link’ becomes bold to show I’m on that page. But as the ‘home’ link doesn’t go to an actual wordpress created page like the others, it just returns to domain.com, it’s not being treated as a current page.

    Is there a way to get it to? I target the current page with this CSS:

    #main-nav li.current_page_item a

    I need the ‘home’ link to be bold when first going to the site, as well as when it is clicked on from elsewhere on the site.

    Really appreciate any help with this, Thanks.

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

    (@pg73)

    Just to update, I’ve found a solution to the problem, the code needed is as below:

    <div id="main-nav">
    	<ul>
    		<li <?php if (is_home()){echo 'class="current_page_item"';}?>><a href="<?php bloginfo('url'); ?>/">Home</a></li>
    		<?php wp_list_pages('title_li=&depth=1&exclude='); ?>
    	</ul>
    </div>
Viewing 1 replies (of 1 total)
  • The topic ‘Can ‘Home’ be treated as ‘Current Page’’ is closed to new replies.