Forums

Different sidebar by page id (2 posts)

  1. danw1986
    Member
    Posted 3 months ago #

    Hello,

    Currently I have a number of different sidebars on my Wordpress website for each different parent page, for example this is how I currently determine which sidebar is shown on what page

    if (is_page(array(130,1425,1367,1421,1601,1821,1184,843,2233,829,2235,823,858,845,865,2231,2223,2229,872,869,867,863,2350))) {
    /*Events Sidebar*/
    
    	include(TEMPLATEPATH . '/sidebar-events.php');
    
    }
    
    elseif (is_page(array(28,91,92,95,96,97,49,98,106,107,108,109,258,277,291,319,99,103,193,169,94,301,2603))) { /* LtoE Sidebar*/
    
    	include(TEMPLATEPATH . '/sidebar-learn-earn.php');
    
    }

    Each time I add a new page I have to manually input the page id for the content in sidebar.php

    Is there a way of getting wp_list_pages - child_of=' for example to get the page ids automatically?

    Many thanks

  2. alanft
    Member
    Posted 3 months ago #

    $post->post_parent will give you the ID of the pages' parent page if that's any help

Reply

You must log in to post.

About this Topic