• Resolved jdunneirl

    (@jdunneirl)


    I am trying to add the tag strong inside the a href piece, here is my code it works for the first element but not the second any ideas?

    I want to make it look like this in the end

    <li><a href="./"><strong>About us</strong></a><em> [2]</em></li>
    Thanks

    John

    <br />
     <?php</p>
    <p>				$my_pages = wp_list_pages('echo=0&title_li=&depth=1');</p>
    <p>				$pieces = explode('"', $my_pages);<br />
    				$i = 6;<br />
    				$j = 5;<br />
    				$limit = count($pieces);<br />
    				for (;$i<$limit;) {<br />
    				$tmp1 = '><strong>'.$pieces[$j].'</strong>';<br />
    				$pieces[$i] = $tmp1;<br />
    				$i = $i+6;<br />
    				$j = $j+6;<br />
    				} </p>
    <p>				$tmp2 = implode('"',$pieces);</p>
    <p>				echo $tmp2;<br />
       				// echo "<!--".$tmp2."-->";</p>
    <p>			?></p>
    <p>

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter jdunneirl

    (@jdunneirl)

    <li><a href="./" accesskey="2"><strong>About us</strong></a><em> [2]</em></li>

    Is what that look likes

    unfortunately, your posted code is somehow distorted (containing <br /> tags etc) so it is impossible to check.

    particular this part for (;$i<$limit;) { is certainly unidentifiable.

    can you repost the code, please?

    also, for any larger amounts of code, please use the http://wordpress.pastebin.com/ .

    what exactly is the purpose of these variables:

    $i = 6;
    $j = 5;

    Thread Starter jdunneirl

    (@jdunneirl)

    Perhaps i am going the wrong way about what I am trying to do,

    I have a list of pages in wordpress and i wish to make a navigation bar out of them, the navigation needs to look like this,

    <li><a href="./" accesskey="2"><strong>About us</strong></a><em> [2]</em></li>

    The code above is an adaptation of

    http://www.wantusiak.com/wordpress/wordpress-modify-wp_list_pages

    Sorry again if this is really obvious, and thanks for the help

    <?php
    
    				$my_pages = wp_list_pages('echo=0&title_li=&depth=1');
    
    				$pieces = explode('"', $my_pages);
    				$i = 6;
    				$j = 5;
    				$limit = count($pieces);
    				for (;$i<$limit;) {
    				$tmp1 = '><strong>'.$pieces[$j].'</strong></a></li>';
    				$pieces[$i] = $tmp1;
    				$i = $i+6;
    				$j = $j+6;
    				} 
    
    				$tmp2 = implode('"',$pieces);
    
    				echo $tmp2;
       				// echo "<!--".$tmp2."-->";
    
    			?>
    			</ul>

    John

    this line that controls the looping through your fragments:

    for (;$i<$limit;) {

    is actually ok.

    however, the rest of the code is not quite clear to me.

    where does you requirement come from:

    the navigation needs to look like this,

    <li><a href="./" accesskey="2"><strong>About us</strong></a><em> [2]</em></li>

    is this accesskey="2" always the same?
    is the link url supposed to be like this href="./" for all links?

    as for the ‘strong’ – this could easily be styled using css.

    Thread Starter jdunneirl

    (@jdunneirl)

    basically, I dont know wordpress and as a project to learn it i was given an existing sites mark up to convert to wordpress, the css for the navigation focuses around the targeting of elements inside the strong tag,

    Here is the css I need it to obey

    Access key will change but can be in sequance, 1 – 6

    #nav { float: right; list-style: none; margin: 0; padding: 0; }
      #nav li { float: left; margin-right: 1px; font-family: Impact, Charcoal, sans-serif; font-size: 1.8em; }
       #nav li a { display: block; color: #fff; text-decoration: none; padding-right: 4px; background: url(images/menu-bcg.png) 100% 0 no-repeat; text-transform: uppercase; }
        #nav li a strong { display: block; padding: 0 6px 0 10px; line-height: 30px; font-weight: normal; background: url(images/menu-bcg.png) 0 0 no-repeat; }
    	#nav li a:hover,
    	#nav li a.active { background-position: 100% -30px; border: 0px solid #000; }
        #nav li a:hover strong,
        #nav li a.active strong { background-position: 0 -30px; }
       #nav li em { position: absolute; left: -10001px; top: -10001px; }

    Thanks again for the help

    John

    this turned out to be quite different from your linked tutorial:

    http://wordpress.pastebin.com/uAZsuMGq

    Thread Starter jdunneirl

    (@jdunneirl)

    Thank you so much for your help,

    Its working perfectly now, I am guessing this was a common enough error?

    So in summary, what you done was take the pages array explode it, take the elements i need and disregard the rest, I think what I was doing was trying to keep the format that was returned and it messed up

    Thanks again for your help

    John

    you are welcome 😉

    the code from the tutorial somehow got it all wrong – particular this line $tmp2 = implode('"',$pieces); which imploded all the pieces back into the starting state.

    if this is sorted, please mark this thread as ‘resolved’.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Newbie and wp_list_pages’ is closed to new replies.