We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question

Perch Page ID

I think there must be a function to output the Perch's page ID for any particular page. But I can't find it in docs.

I'd like to use it as an ID in the body tag, to target pages with JS and CSS.

Simon Clay

Simon Clay 127 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you mean its database ID?

Simon Clay

Simon Clay 127 points

Yes, I thought that might be a good reference because it won't change throughout the life of the page.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can probably use the following, but exercise caution in relying on it:

perch_page_attribute('pageID')
Simon Clay

Simon Clay 127 points

Thank you, that is working for this scenario:

<body id="<?php perch_page_attribute('pageID'); ?>">