Fallback to top ancestor
-
I liked candell’s post regarding displaying default content if the MCB field is empty. I’ve adapted this slightly and created a function to cut down on the amount of code in my page templates.
function getMCBheadline() { $headlineblock = get_the_block('headline',array('type' => 'one-liner','apply_filters' => false)); $emptyheadline = "This is the default fall-back headline"; if ($headlineblock != "") { echo $headlineblock; } else { echo $emptyheadline; } }
I’m creating a site where each main page has an addtional headline content block with a mission statement. Is there any way to get the content of the main page content block to show on child (or grandchildren) pages if their content block is empty rather than static default text using ‘get_top_ancestor’ or similar? Any help much appreciated.
https://www.ads-software.com/extend/plugins/multiple-content-blocks/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Fallback to top ancestor’ is closed to new replies.