WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] if elseif

[Resolved] if elseif

  • Hi everybody,

    i am starting with php and still so much too learn.I am trying not to create a new template each time i have something new on the page so:

    my code is:<?php

    if ( is_page(’35’)) {wp_list_pages(‘sort_column=menu_order&depth=1&title_li=<h4>discografia</h4>&child_of=35’);}

    elseif (is_tree(’35’)){wp_list_pages(‘sort_column=menu_order&depth=1&title_li=<h4>discografia</h4>&child_of=35’);
    }
    ?>`
    and it works well but what if i want put a div id=nav1 and a divid=nav2 to style inch menu in a different way?… In this case i don t know how to concanate the php..it always give me an error…

    an advice would be very appreciated,

    thanks a lot,

    cheers,
    David

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi David

    Could you tell me the error that it gives you? That way it would help me solve your problem. At the moment I’m not quite sure I understand.

    Michael

    Moderator Michael

    @alchymyth

    Forum Moderator

    (be aware of the <ul> tags that should be around your code already, you need to remove them there and put them within the divs)
    the sequence is to always close the php tags beforde using html, and then open the php tag again before continuing with php.

    <?php
    if ( is_page('35')) { ?>
    <div id="nav1><ul>
    <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=<h4>discografia</h4>&child_of=35'); ?>
    </ul></div>
    <?php }
    
    elseif (is_tree('35')){ ?>
    <div id="nav2"><ul>
    <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=<h4>discografia</h4>&child_of=35'); ?>
    </ul></div>
    <?php } ?>

    Hi alchymyth and f00bar!

    Thanks a lot! that was i needed it! you solved my problem.
    perfect!really appreciated.
    big cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] if elseif’ is closed to new replies.