Forums

Navigation line (7 posts)

  1. davy_yg
    Member
    Posted 4 months ago #

    Hi,

    I am trying to create a navigation line between each menu item.

    header.php

    <ul id="nav">
         <div id="body">
       		<li><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/navline.png" /><?php wp_list_pages('sort_column=menu_order&title_li=');?></li>
            <div id="search"><?php include('search.php'); ?></div>
         </div>
        </div>

    This code only place the navigation line in the beginning of the menu. Basically each menu item must be in between of the navigation line.

  2. peredur
    Member
    Posted 4 months ago #

    Wouldn't you want to use either the link_before or the link_after parameter?

    link_before
    (string) Sets the text or html that precedes the link text inside tag. (This parameter was added with Version 2.7)

    link_after
    (string) Sets the text or html that follows the link text inside
    tag. (This parameter was added with Version 2.7)

    HTH

    PAE

  3. davy_yg
    Member
    Posted 4 months ago #

    header.php

    <li><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/navline.png" /><?php wp_list_pages('sort_column=menu_order&title_li=&link_after=<img src="'<?php echo get_stylesheet_directory_uri(); ?>/images/navline.png>'");?></li>

    Parse error: syntax error, unexpected '?' in C:\xampp\htdocs\wordpress\wp-content\themes\ocklaw\header.php on line 28

  4. peredur
    Member
    Posted 4 months ago #

    Well, you've got a syntax error somewhere.

    I'd try to use the args array syntax since it makes things a bit clearer IMHO. Something like:

    <?php
            $args = array(
    	  'title_li'     => '',
    	  'sort_column'  => 'menu_order',
    	  'link_after'   => '<img src="<?php bloginfo(\'stylesheet_url\'); ?>/images/navline.png" alt="" />'
            )
    ?>

    You then pass $args to your call to wp_list_pages.

    But you may still have to play around with that to ensure that the syntax is correct. For example I'm pretty sure that I needed to escape the single quotes around "stylesheet_url", but I'm not entirely sure. You have to mess with these things until you get them right.

    Since I don't have any way of debugging your code, I can only guess.

    Others might see the problem straightaway, of course. I'm not the world's best developer.

    But try that, anyway, and let's see what happens.

    Cheers

    PAE

  5. davy_yg
    Member
    Posted 4 months ago #

    header.php

    <?php
           $args = array(
    	  'title_li'     => '',
    	  'sort_column'  => 'menu_order',
    	  'link_after'   => '<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/navline.png" alt="" />'
            )
    		?>

    The navigation disappeared.

  6. peredur
    Member
    Posted 4 months ago #

    Well, as I said, I can't do your debugging for you. You need to do all the normal things developers do to get their code working. Without actually being there with you, I can't help a lot.

    Some of the things I'd do would include using print_r() statements to display the output of some of the commands to check they're returning what I expect them to return.

    Using the link_before or link_after parameters is definitely the way to go, you just have to work out what the values you give to them are returning.

    I know it's a pain, but it's what developers do all day.

    Sorry I can't be more helpful.

    Cheer

    PAE

  7. davy_yg
    Member
    Posted 3 months ago #

    I cannot find which other forums that can help me out in this wordpress stuff. So, if you or anybody else perhaps can answer ?

    This code produces: line after each menu item. Just one problem the image still appears: x. How to make it work ?

    header.php

    <?php wp_list_pages('sort_column=menu_order&title_li=&link_after=<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/navline.png" alt="" />');?>

    This code also produces the same result:

    header.php

    <?php
           $args = array(
    	  'title_li'     => '',
    	  'sort_column'  => 'menu_order',
    	  'link_after'   => '<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/navline.png" alt="" />'
            );
    
    	   wp_list_pages($args);
    		?>

Reply

You must log in to post.

About this Topic

Tags