Support » Fixing WordPress » Page.php —> problem Showing Current Page in select!

  • Hi
    I want to display current page [selected=selected] and parent page [selected=selected] in select form.

    So I’ve put in page.php for current parent page:

    	    $include_page_ids = array('7','8','11','12','13','14','15','16','17','18','19','21','23','24','25'); //also the order of appearance
    	    for ($i = 0;$i < count($include_page_ids);$i++) {
    		$args = array('title_li'=>'','include' => $include_page_ids[$i],'link_before'=>'<option>','link_after'=>'</option>');
    		wp_list_pages( $args );

    and for current page:

    if(wp_list_pages('child_of='.$post->ID.'&echo=0&exclude=2')) {
    echo "<p>";
    wp_list_pages('title_li=&child_of='.$post->ID.'&exclude=2'.'link_before= <option selected=selected>'.'link_after=</option>');
    echo "</p>";
    elseif(get_the_title($post->post_parent) != the_title(' ' , ' ',false)) {
    echo "<select>";
    wp_list_pages('child_of='.$post->post_parent.'&title_li=&exclude=2'.'link_before=> <option>'.'link_after=></option>');
    echo "</select>";
    } ?>

    and the parent page seems to almost work [doesn’t display selected=selected] while current page does not at all…

    Changing the select filed should change the url as well…

    Do you have an idea how to work it out?



Viewing 1 replies (of 1 total)
  • In the first case, I don’t think you can do that with wp_list_pages. You need to conditionally insert ‘selected=”selected”‘ and I don’t know of any way to do that with wp_list_pages, although there is a wp_list_pages hook that you might be able to hook some regex to.

    In the second case, it looks like you are missing an ampersand before the ‘link_before=’ and before the ‘link_after=’. I confess, however, that I really hate that ‘url get string’ style parameter mechanism. It confuses me and I never use it, so I may have missed something.

Viewing 1 replies (of 1 total)
  • The topic ‘Page.php —> problem Showing Current Page in select!’ is closed to new replies.