Home › Forums › General Issues › Custom Page Builder › Reply To: Custom Page Builder
ok, so i have managed to get an accordion to display in my page editor, but not sure if this will close the accordion properly? and how to display this in my page builder php properly?
json for accordion:
{
"key": "561538dcw4334t",
"name": "accordion_row",
"label": "Accordion Row",
"display": "block",
"sub_fields": [
{
"key": "field_5f90caa048f59",
"label": "accordion-open",
"name": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_5f95e677d32d0",
"label": "Accordion Title",
"name": "accordion_title",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
},
{
"key": "field_5f95e686d32d1",
"label": "Accordion Content",
"name": "accordion_content",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 1,
"delay": 0
},
{
"key": "field_5f90cab348f5a",
"label": "accordion-end",
"name": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 1
}
],
"min": "",
"max": ""
},
PHP in page builder plugin to display the accordion:
private function getSection_accordion() {
$blocks = get_sub_field('accordion_row');
$html = '';
if( count($blocks) > 0 ) :
foreach($blocks as $block) {
$html .= '<div class"accordion-title">';
$html .= $block['accordion-title'];
$html .= '</div>';
$html .= '<div class"accordion-content">';
$html .= $block['accordion_content'];
$html .= '</div>';
};
endif;
return $html;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.