Forums

How to modify the URLs of wp_list_pages?? (7 posts)

  1. hannemaatje
    Member
    Posted 7 months ago #

    I want to modify the URLs of wp_list_pages; I want to add a #content after the URL, so you skip to that point in the page.

    I would think this is very simple and there are many solutions, but I only found one post on it. I just don't know how to implement this:

    Can anyone point me in the right direction?

  2. keesiemeijer
    moderator
    Posted 7 months ago #

    In stead of wp_list_pages use this:

    <?php
    $pages = wp_list_pages('echo=0');
    echo preg_replace('/\" title=\"/','#content" title="', $pages);
    ?>

    or put this in your theme's functions.php

    add_filter('wp_list_pages', 'add_to_link');
    function add_to_link($pages) {
            return preg_replace('/\" title=\"/','#content" title="', $pages);
    }
  3. hannemaatje
    Member
    Posted 7 months ago #

    Hoera!
    Het is gelukt, dankjewel!

  4. keesiemeijer
    moderator
    Posted 7 months ago #

    You're welcome.

  5. Ramzii
    Member
    Posted 7 months ago #

    Een vraagje aansluitend op dit onderwerp:

    I have the following code:

    <ul id="navigatie_baby">
    <?php wp_list_pages('title_li='); ?>
    </ul>

    And I styled each li with a background like so:

    #navigatie_baby li.page_item{
    	background:url(../images/navigatie/li_menu.jpg) no-repeat 0 ;
     	background-position:0px 0px;
    	width:260px;
    	padding:14px 13px 13px 13px ;
    	list-style-type:none;
    	z-index:0;
    	position:relative;
    	}

    How do I get each background image clickable?

    Currently only the titles are clickable.... their assigned background is not, and kinda stuck.

    Thanks

  6. hannemaatje
    Member
    Posted 7 months ago #

    Maybe you could try to display your <a href> tags in your wp-list-pages as block-elements, and then style them as you would your
    <li>, like so:

    #navigatie_baby li.page_item a {
            display:block;
    	background:url(../images/navigatie/li_menu.jpg) no-repeat 0 ;
     	background-position:0px 0px;
    	width:260px;
    	padding:14px 13px 13px 13px ;
    	list-style-type:none;
    	z-index:0;
    	position:relative;
    	}

    Tell me, does this work?

  7. Ramzii
    Member
    Posted 7 months ago #

    I cant believe it was that simple haha, thanks so much ;)

    Oftewel hartelijk dank ouwe (:

Reply

You must log in to post.

About this Topic