• I have a workaround for this problem but I would like to understand it. I’m using the azul theme, somewhat modified, and I only have a blog, about page, sub page (not on nav), and only three categories which I do like to show on the nav. The code below works, but…

    <!--    <?php wp_page_menu('show_home=Blog'); ?> -->
            <ul>
    
    <!--            <li <?php if(is_home()){echo 'class="current_page_item"';}?>><a href="<?php get_bloginfo('url'); ?>">Blog</a></li> -->
                    <li <?php if(is_home()){echo 'class="current_page_item"';}?>><a href="https://marlacorinne.4parkers.com">Blog</a></li>
    
                    <?php wp_list_pages('title_li=&amp;depth=1'); ?>
                    <?php wp_list_categories('title_li=&amp;depth=0'); ?>
    
            </ul>

    you can see that I have hard-coded the url for my blog. The line before produces a nav bar that looks identical on all the pages, but the url for the first button, Blog (home), is only correct if you are in fact on that page. It is the url of the current page, whatever that page might be.

    I’ve tried get_bloginfo(‘url’) and ‘wpurl’ with the same results, and also get_option(‘home’). All with the same problem.

    Can someone explain why? and do I need to finally go read about The Loop now? I’ve gotten this far without it, but I do plan to read it eventually…

    thx

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try:

    <li <?php if(is_home()) {echo 'class="current_page_item"';}?>><a href="<?php bloginfo('url'); ?>">Blog</a></li>

    Thread Starter marlacorinne

    (@marlacorinne)

    Thank you esmi!

    That worked perfectly, and in looking at the rest of the file, bloginfo is used repeatedly and get_bloginfo not once. So that makes sense, and I do understand the difference between the two as documented here (first paragraph, last sentence).

    But I think I will now go and learn about The Loop because I think I should know when php code will be writing stuff straight to the browser and when it should be returning results for more php code to manipulate.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘url for home nav button wrong sometimes, get_bloginfo’ is closed to new replies.