Forums

[resolved] wp_page_menu doesn't include link_after text in Home link (5 posts)

  1. pleuriticus
    Member
    Posted 3 years ago #

  2. Chantal Coolsma
    Member
    Posted 3 years ago #

    How did you resolve this? Can you tell us?

  3. pleuriticus
    Member
    Posted 3 years ago #

    Instead of having wp-page-menu include a home link on the menu list, I added a page in the admin control panel called Home, and set my posts to display on that page. Then, added my span and /span tags to the wp_page_menu to appear before and after each menu item link.

    Problem was that when you use wp_page_menu, and you do not have a page called home - so your home is essentially just your posts page, and you ask wp_page_menu to include a link to that home page, it does not add any of the before and after text you specify in the wp_page_menu function call.

    Still think this should either be fixed in the wp_page_menu function - or an actual home page for posts should be generated by dafault on install. It is rather inelegant, as it is, to have to add the page and assign posts to it in order to get the specified before and after link text/tags to appear on the home link, so you don't have to make a special button for it when you're trying to make two-piece expanding tabs or menu buttons.

  4. dbreece
    Member
    Posted 3 years ago #

    I just ran into this same problem, and I agree, there should be a way to add the link_before and link_after tags to the Home link.

    I found that you can get adequate results by adding a regular link to Home right in front of the wp_page_menu call, with the <span> tags in place.

    <a id="homelink" href="<?php echo get_option('home'); ?>"><span>Home</span></a>
    
    <? wp_page_menu(array('link_before' => '<span>',
                          'link_after'	=> '</span>',
                          'menu_class' => 'navbar')); ?>

    I had to do a little css massaging to get it to line up with the
    generated links, but the end result is seamless.

  5. lukemiller
    Member
    Posted 2 years ago #

    I'm new to WP so maybe this was fixed within the last two months but here's what I found to solve the problem:

    <?php wp_page_menu( array( 'show_home' => 'Blog', 'sort_column' => 'menu_order' ) ); ?>

    Where "Blog" is the text you want for the button link.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.