WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] if elseif (4 posts)

  1. davidandre
    Member
    Posted 4 years ago #

    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

  2. f00bar
    Member
    Posted 4 years ago #

    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

  3. alchymyth
    Forum Moderator
    Posted 4 years ago #

    (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 } ?>
  4. davidandre
    Member
    Posted 4 years ago #

    Hi alchymyth and f00bar!

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags