Support » Fixing WordPress » if elseif

  • Resolved davidandre


    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 always give me an error…

    an advice would be very appreciated,

    thanks a lot,


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.




    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.

    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'); ?>
    <?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'); ?>
    <?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 ‘if elseif’ is closed to new replies.