I have a site with a blog and with 4 sections that contain Pages. In the Dashboard I have used the Page Order number column to give each of the four Page sections a range of numbers different from the other three sections. Say, the “About” section is from 1000 to 1999, and all pages in this section are multi-level descendants of the About page. Then I set the “Contact” section to Page Order numbers from 2000 to 2999 and make all pages in that section into multi-level descendants of the Contact page.
For example, something simple. Say I want to give all pages in the About section a green background, while giving all the pages in the Contact section a yellow background, to help people know what section they are in.
I can think of two ways I could do that. However, I haven’t been able to figure out how to do either one.
Option 1: Write a PHP function that uses an IF statement, like “if (is_page() && IF(Page Order Number is greater than 999 and less than 2000)), then set background to green. My problem is that I can’t find a variable that I can use to get the Page Order Number for the current page so that I can use it in the IF statement. The only Page Order thing I have found is sort_column=menu_order, which is not what I need. Does anyone know how to reference the Page Order Numbers set in the Dashboard in a PHP IF statement? Is there a specific get_ or variable that will obtain the current_page’s Page Order Number?
Option 2: Write a PHP function that uses an IF statement to check the page to see if it is a descendant of the About page or the Contact page. I’ve only been able to find a parent/child link which only goes up one level, not to the Parent page of all the pages in that section. If I am on a page that is 5 levels down from the parent About page, how do I test for the About page or the Contact page as the ultimate parent page for the current_page? If(is_page() && current_page has ultimate parent page of About), then make background green. Is there an ancestor variable that will obtain the About page as ultimate parent?
Of course, maybe there is an Option 3 that is better than either of these.
I am pretty new to WordPress. Any help you could give me in resolving this will be very greatly appreciated. Thank you!
- The topic ‘Trying to set different backgrounds (say) for different sets of Pages’ is closed to new replies.