if tree (3 posts)

  1. lucasdegen
    Posted 2 years ago #


    I'm building a website linking with an external CRM system. The websites is showing jobs and uses a plugin to show jobs in a page and jobs in a widget.

    The challenges:

    • Have two homepages
    • Show different content per page

    So these are the tricks I've used and I would like to share with you. I'm a front-ender with bottom PHP knowledge.

    I've used tree functionality to show content in a custom Widget Y

    if ( (is_tree(6)) || (is_tree(4)) ) {
    dynamic_sidebar( 'widget-area-y' );
    echo '<div class=banner><a href=""><img src = "' . get_bloginfo ( 'template_url' ) . '/images/banner.jpg" alt = "' . get_the_title($ID) . '" /></a></div>';

    Above I call a widget and add an image under the widget.

    On this website I've used two homepages..
    One for people looking for a job, the other homepage for people offering a job. Each homepage having a slider-image. On a child pages I want to show an section image.

    I've put this in my header to show a slider on the frontpage (homepage1) and page ID 6 (homepage2)

    if (is_front_page()) {
    //add slider image
    elseif (is_page('6')) {
    //add slider image
    //Now add code to show section image for all pages being child of page ID6
    elseif (is_tree('6' )) {
    echo '<img src = "' . get_bloginfo ( 'template_url' ) . '/images/section/6.jpg" alt = "' . get_the_title($ID) . '" />';
    //don't forget to add a black image for 404 and search page
    elseif ('is_404()' || 'is_search()') {
  2. Andrew
    Forum moderator
    Posted 2 years ago #

    You may be better suited using a switch statement instead of multiple ifs.

  3. lucasdegen
    Posted 2 years ago #

    Thank you Andrew Nevins I will look into PHP switch statement. I'm a noob at PHP.

Topic Closed

This topic has been closed to new replies.

About this Topic