I’ve used the following code to assign a custom background to the page (a ‘parent page’), and want to have the same background appear on the child pages:
Sorry, PicnicTutorials - not with you. Which class do you mean, and how would I put it on my child pages, please?
I know I can get that custom background on each of the child pages just by repeating the code with the ID of each child page:
For example, the background can be applied to the first child page (‘Ray De Motte’) as follows:
Repeating the code like this seems long-winded, and is probably a reflection of my ignorance of a better option. I guess I’m just asking if there is a quicker, more concise way to have this custom background applied to all the child pages under the ‘Personal Perspectives’ parent. Been messing around, but haven’t found a way yet.
Could you explain what you mean by ‘parent’ and ‘child’ pages? It doesn’t mean anything specific in terms of CSS. Do you mean that you want each page in the /personal-perspectives/ section to have the same background?
Sorry Ralph - wasn’t aware that parent/child page terminology was Wordpress-speak and not generally used. Yes, your interpretation is correct: I want each page in the /personal-perspectives/ section to have the same black-and-white collage background (ie: as the ‘Personal Perspectives’ page that appears on the nav menu).
Do I need to repeat the same code as above with each of the child page’s id numbers, or can I somehow add those id numbers to the code quoted?
in one way or another you will need to add the class to the pages you want to have the bg.
there are two strategies you can follow.
edit the heather page in the theme ( if you have access to it) and use a general class. something like :
$custom= array (139,139,150)// the page IDs you want to have the bg
$page_object = get_queried_object();
$page_id = get_queried_object_id();
<body class="<? if (in_array ($page_id , $custom)) {echo "customClass";} ?>">
.customClass{ your rules here...}
However since you already know you theme is adding the .page-id-xxx to your body tag you could just edit the CSS
body.page-id-318,body.page-id-319,body.page-id-320,body.page-id-321{ your rules...; }