Hi, no need to “connect“, ACF atomatically lists all your post types and since bbpress has 3 post types they are listed. Just copy your bbpress theme files to your theme folder (https://codex.bbpress.org/themes/theme-compatibility/getting-started-in-modifying-the-main-bbpress-template/) and put the ACF code to it.
I am using bbpress and I can chose the 3 posttypes from the forum plugin for my fields so I’m sure when you put the ACF code into the template files of the forum it works as with all other posttypes:
Do you use Bootstrap? I am working on something similar, my attempt is to have standard width that you can edit.
<?php if ( have_rows( 'my_repeater' ) ) : ?>
<?php while ( have_rows( 'my_repeater' ) ) : the_row(); ?>
<?php $url = get_sub_field( 'url' ); ?>
<?php if ( $url ) { ?>
<a href="<?php echo $url['url']; ?>" target="<?php echo $url['target']; ?>"><?php echo $url['title']; ?></a>
<?php } ?>
<?php endwhile; ?>
<?php else : ?>
<?php // no rows found ?>
<?php endif; ?>
The same, just use “get_sub_field”.
If you struggle with the code there is a premium plugin that gives you all the code: https://hookturn.io/downloads/acf-theme-code-pro/
I suggest you to use “Slick Slider” it is way more flexible, faster, better, everything. I know it does not help but when I see someone using this retarded OWL slider I want to prevent them to make a big mistake 😉
Sure, I do this every day – use the “Link” element. It gives you the URL and the Title:
https://www.advancedcustomfields.com/resources/link/
<?php
$link = get_field('link');
if( $link ):
$link_url = $link['url'];
$link_title = $link['title'];
$link_target = $link['target'] ? $link['target'] : '_self';
?>
<a class="button" href="<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?></a>
<?php endif; ?>
I have debated this as well and I’ve just started adding styles directly into the page, the ugly method you mentioned. Will it be supported in the future? Browsers rarely remove support for things because it would mean breaking thousands of sites.
That is a good point, I do this since years and had no problem in any browser – maybe I’ll stick with it, too. Less work.
If it helps you, import this as “something.json” in your ACF and check it out.
[
{
"key": "group_5d75feeccbdc9",
"title": "Spalten",
"fields": [
{
"key": "field_5d725da67101e",
"label": "Spalten",
"name": "columns",
"type": "flexible_content",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"layouts": {
"layout_5d720da0975d2": {
"key": "layout_5d720da0975d2",
"name": "columns_row_row_h2",
"label": "Headline (H2)",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671025",
"label": "Text",
"name": "text",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d720ea2b59b6": {
"key": "layout_5d720ea2b59b6",
"name": "columns_row_row_h3",
"label": "Headline (H3)",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67102c",
"label": "Text",
"name": "text",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d6f7653437a2": {
"key": "layout_5d6f7653437a2",
"name": "columns_row_row_intro",
"label": "Einleitung",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671033",
"label": "Editor",
"name": "columns_row_row_intro_editor",
"type": "wysiwyg",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"577ba52f12d8c": {
"key": "577ba52f12d8c",
"name": "columns_row_row_wysiwyg",
"label": "Editor",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67103a",
"label": "Editor",
"name": "columns_row_row_wysiwyg_editor",
"type": "wysiwyg",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d6f7c304ec2a": {
"key": "layout_5d6f7c304ec2a",
"name": "columns_row_row_card",
"label": "Karte",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671041",
"label": "Bild",
"name": "columns_row_row_card_img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "",
"acfe_thumbnail": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671042",
"label": "Header",
"name": "columns_row_row_card_header",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671043",
"label": "Editor",
"name": "columns_row_row_card_editor",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671044",
"label": "Button (Mehr Info)",
"name": "columns_row_row_card_button",
"type": "link",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d6f95c598351": {
"key": "layout_5d6f95c598351",
"name": "columns_row_row_feature",
"label": "Feature",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67104b",
"label": "Bild",
"name": "img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "id",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "",
"acfe_thumbnail": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104c",
"label": "Headline",
"name": "headline",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104d",
"label": "Editor",
"name": "editor",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104e",
"label": "Button (Mehr Info)",
"name": "button",
"type": "link",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104f",
"label": "Optionen",
"name": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_5d725da671050",
"label": "Bild rechts",
"name": "img_right",
"type": "true_false",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"message": "Bild rechts",
"default_value": 0,
"ui": 0,
"ui_on_text": "",
"ui_off_text": "",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d7f731463ff4": {
"key": "layout_5d7f731463ff4",
"name": "columns_row_row_b",
"label": "Bild (volle Breite)",
"display": "block",
"sub_fields": [
{
"key": "field_5d7f731463ff5",
"label": "Bild",
"name": "img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": ""
}
],
"min": "",
"max": ""
},
"layout_5d7221914e469": {
"key": "layout_5d7221914e469",
"name": "columns_row_row_bt",
"label": "Bild (volle Breite) + Text",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671057",
"label": "Bild",
"name": "img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "",
"acfe_thumbnail": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671058",
"label": "Editor",
"name": "editor",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d024db252b54": {
"key": "layout_5d024db252b54",
"name": "columns_row_row_trenner",
"label": "Trenner",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671059",
"label": "Info",
"name": "",
"type": "message",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"message": "Ein Trennelement das die Reihe mit Spalten davor beendet (erzwungener Umbruch).",
"new_lines": "wpautop",
"esc_html": 0
},
{
"key": "field_5d725da67105a",
"label": "Optionen",
"name": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_5d725da67105b",
"label": "Trenner Design",
"name": "_inse_trenner_design",
"type": "radio",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"choices": {
"stroke": "Linie",
"ghost": "Unsichtbar"
},
"allow_null": 0,
"other_choice": 0,
"save_other_choice": 0,
"default_value": "",
"layout": "vertical",
"return_format": "value",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67105c",
"label": "Trenner Design Optionen",
"name": "_inse_trenner_design_options_1_gr",
"type": "group",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5d725da67105b",
"operator": "==",
"value": "stroke"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"layout": "block",
"sub_fields": [
{
"key": "field_5d725da67105d",
"label": "Farbe",
"name": "_color",
"type": "color_picker",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "#fff",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67105e",
"label": "Stärke",
"name": "_width",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": 3,
"placeholder": 3,
"prepend": "",
"append": "Pixel",
"min": 1,
"max": "",
"step": "",
"acfe_validate": false,
"acfe_update": false
}
]
}
],
"min": "",
"max": ""
},
"layout_5d70cec989566": {
"key": "layout_5d70cec989566",
"name": "columns_row_row_accordion",
"label": "Accordion",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671065",
"label": "Accordion Zeile",
"name": "accordion_zeile",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"collapsed": "",
"min": 0,
"max": 0,
"layout": "block",
"button_label": "Accordion Zeile hinzufügen",
"sub_fields": [
{
"key": "field_5d725da671066",
"label": "Titel",
"name": "accordion_titel",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671067",
"label": "Accordion Text",
"name": "accordion_text",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "basic",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
]
}
],
"min": "",
"max": ""
},
"layout_5d7114e0e3584": {
"key": "layout_5d7114e0e3584",
"name": "columns_row_row_downloads",
"label": "Downloads",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67106e",
"label": "Downloads",
"name": "_listdl",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": false,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"min": 0,
"max": 0,
"layout": "table",
"button_label": "",
"collapsed": "",
"sub_fields": [
{
"key": "field_5d725da67106f",
"label": "Download",
"name": "_singledl",
"type": "file",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5d725da671070",
"operator": "!=",
"value": "1"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "id",
"library": "all",
"min_size": "",
"max_size": "",
"mime_types": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671070",
"label": "Externer Download",
"name": "_singledl_extern_choice",
"type": "true_false",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "20",
"class": "",
"id": ""
},
"acfe_permissions": "",
"message": "Externe Datei",
"default_value": 0,
"ui": 0,
"ui_on_text": "",
"ui_off_text": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671071",
"label": "Download extern",
"name": "_singledl_extern",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5d725da671070",
"operator": "==",
"value": "1"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "https:\/\/www. ...",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
}
]
}
],
"min": "",
"max": ""
},
"layout_5d7627e37a23f": {
"key": "layout_5d7627e37a23f",
"name": "columns_row_row_video",
"label": "Video",
"display": "block",
"sub_fields": [
{
"key": "field_5d7627fd7a240",
"label": "Video",
"name": "video",
"type": "oembed",
"instructions": "Geben Sie in dem Feld \"URL eingeben\" den Link zum Video ein. Beispiele:<br \/>\r\nhttps:\/\/www.youtube.com\/watch?v=jNQXAC9IVRw<br \/>\r\nhttps:\/\/vimeo.com\/channels\/staffpicks\/98741946",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"width": "",
"height": ""
}
],
"min": "",
"max": ""
},
"layout_5d762bb5c8563": {
"key": "layout_5d762bb5c8563",
"name": "columns_row_row_personen",
"label": "Personen",
"display": "block",
"sub_fields": [
{
"key": "field_5d762c3ac8564",
"label": "Person",
"name": "person",
"type": "relationship",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"post_type": [
"person"
],
"taxonomy": "",
"filters": [
"search"
],
"elements": [
"featured_image"
],
"min": "",
"max": "",
"return_format": "object"
},
{
"key": "field_5d7631151dde7",
"label": "Details",
"name": "_ausblenden",
"type": "checkbox",
"instructions": "Entfernen Sie den Haken der Felder welche nicht auf der Website angezeigt werden sollen (gilt dann nur für diese Seite).",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"pos": "Position",
"email": "E-Mail",
"telefon": "Telefon",
"address": "Adresse",
"foto": "Foto"
},
"allow_custom": 0,
"default_value": [
"pos",
"email",
"telefon",
"address",
"foto"
],
"layout": "horizontal",
"toggle": 0,
"return_format": "value",
"save_custom": 0
}
],
"min": "",
"max": ""
},
"layout_5d765d2193ab3": {
"key": "layout_5d765d2193ab3",
"name": "columns_row_row_prozentanzeige",
"label": "Prozentanzeige",
"display": "block",
"sub_fields": [
{
"key": "field_5d765ef920e87",
"label": "Prozent Balken",
"name": "prozent_balken",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"collapsed": "",
"min": 0,
"max": 0,
"layout": "table",
"button_label": "",
"sub_fields": [
{
"key": "field_5d765f1020e89",
"label": "Prozent",
"name": "prozent",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "20",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "%",
"maxlength": ""
},
{
"key": "field_5d765f0520e88",
"label": "Text",
"name": "text",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "80",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
}
]
}
],
"min": "",
"max": ""
},
"layout_5d766e2e96670": {
"key": "layout_5d766e2e96670",
"name": "columns_row_row_seniorenzentrum",
"label": "Einrichtung",
"display": "block",
"sub_fields": [
{
"key": "field_5d766f4996671",
"label": "Einrichtung",
"name": "einrichtung",
"type": "relationship",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"post_type": [
"einrichtung"
],
"taxonomy": "",
"filters": [
"search"
],
"elements": [
"featured_image"
],
"min": "",
"max": "",
"return_format": "object"
}
],
"min": "",
"max": ""
},
"layout_5d9df2c47b33a": {
"key": "layout_5d9df2c47b33a",
"name": "columns_row_row_jobsfeed",
"label": "Stellenangebote (Feed)",
"display": "block",
"sub_fields": [
{
"key": "field_5d9df2dc7b33b",
"label": "Info",
"name": "",
"type": "message",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "Aktuelle Stellenangebote von \"<strong>https:\/\/www.awo-stellenboerse.de<\/strong>\/stellenboerse-hamburg-seniorenwohnen.json\".",
"new_lines": "wpautop",
"esc_html": 0
}
],
"min": "",
"max": ""
}
},
"button_label": "Spalte hinzufügen",
"min": "",
"max": ""
}
],
"location": [
[
{
"param": "post_template",
"operator": "==",
"value": "tpl-sidebar_left.php"
}
],
[
{
"param": "post_template",
"operator": "==",
"value": "tpl-fullwidth_m.php"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": ""
}
]
@xuzo – It is save to use this, even if there is only one accordion. You will anyway need a uniqe ID for the rows of the accordion.
In this example I use get_row_index()
to give the ID:
<?php if ( have_rows('columns') ) : ?>
<div class="row">
<?php while ( have_rows('columns') ) : the_row(); ?>
<?php if ( get_row_layout() == 'columns_row_row_accordion'): ?>
<section class="column column_accordion __ col-12">
<?php $Acc = get_row_index(); ?>
<?php if( have_rows('accordion_zeile') ) : ?>
<div id="accordion_<?php echo $Acc; ?>">
<?php while ( have_rows('accordion_zeile') ) : the_row(); ?>
<div class="card">
<div class="card-header" id="heading_<?php echo get_row_index(); ?>_<?php echo $Acc; ?>">
<h4 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse_<?php echo get_row_index(); ?>_<?php echo $Acc; ?>" aria-expanded="true" aria-controls="collapse_<?php echo get_row_index(); ?>_<?php echo $Acc; ?>">
<?php the_sub_field("accordion_titel"); ?>
</button>
</h4>
</div>
<div id="collapse_<?php echo get_row_index(); ?>_<?php echo $Acc; ?>" class="collapse" aria-labelledby="heading_<?php echo get_row_index(); ?>_<?php echo $Acc; ?>" data-parent="#accordion_<?php echo $Acc; ?>">
<div class="card-body">
<?php the_sub_field("accordion_text"); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php endif; ?>
And in this example I use “uniqid” to give an ID:
https://codepen.io/herrfischer/pen/yqrZzm
Feel free to ask if you need more help.
Same problem here with ACF Pro 5.8.4.
I had activated
Now I deeded to activate
,too. So I have
Works.
This is the way I load the script in my functions.php:
wp_register_script('aa_js_googlemaps_script', 'https://maps.googleapis.com/maps/api/js?v=3.exp&key=XXX'); // with Google Maps API fix
wp_enqueue_script('aa_js_googlemaps_script');
and
function my_acf_init() {
acf_update_setting('google_api_key', 'XXX');
}
add_action('acf/init', 'my_acf_init');
<?php echo str_replace('https://www.youtube.com/embed', 'https://www.youtube-nocookie.com/embed', get_field('my_video')); ?>
<?php echo str_replace('https://www.youtube.com/embed', 'https://www.youtube-nocookie.com/embed', get_field('my_video')); ?>
Where to put your code? in the “functions.php”?
Maybe I could use an easier method. Like this (extra while loop with $i++) to get unique classes:
<?php if( have_rows('_post_slider') ) : ?>
<?php $flexibleSlider = 0 ?>
<?php while( have_rows('_post_slider') ) : the_row(); ?>
<?php $flexibleSlider++; ?>
<?php endwhile; ?>
<div class="row slider-wrapper">
<div class="col-md-12">
<div class="slider_inner slider-<?php echo $flexibleSlider; ?> ">
<?php
$count_dataindex = 0;
$count_dataid = 0;
?>
<?php while( have_rows('_post_slider') ) : the_row(); ?>
<?php $count_dataindex++; ?>
<article class="" data-index="<?php echo $count_dataindex; ?>" data-slidertitle="<?php the_sub_field('_headline'); ?>">
<?php $image = get_sub_field('_bild'); ?>
<figure style="background-image: url(<?php echo $image['sizes']['img-l']; ?>)"></figure>
<?php if ( get_sub_field('_headline') ) : ?>
<div class="slider-headline" data-id="<?php echo $count_dataid; ?>">
<?php echo get_sub_field('_headline'); ?>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</div>
</div>
</div>
<script>
jQuery(document).ready(function($){
$('.slider-<?php echo $flexibleSlider; ?> ').slick({
infinite: true,
slidesToShow: 1,
slidesToScroll: 1
});
});
</script>
<?php endif; ?>
EDIT: Hm no. I get “slider-4”, “slider-3”, “slider-3” … .
“I would likely create another meta_key to hold the ID so it remains consistent.”
How to do this? Sounds interesting.
I use this i a theme:
$date_now = date('Y-m-d H:i:s');
// WP_Query arguments
$args = array(
'posts_per_page' => 3,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'end_date',
'compare' => '>=',
'value' => $date_now,
'type' => 'DATETIME'
)
),
'order' => 'ASC',
'orderby' => 'date',
'meta_key' => 'end_date',
'meta_type' => 'DATE'
);
// The Query
$query = new WP_Query( $args );
Sorry, it must be “$colors_ID”. With “uniqid()” I give the elements a unique ID, use it as a CSS Class and style it. The <style> section is somewhere in the document, I want to somehow collect these and put it to the headers (header.php) style section.
And here is my code for Bootstrap 4.
I change the IDs name (#accordion) because I want to use multiple accordions on one page.
<?php if( have_rows('_accordion_zeile') ): $accordion++; ?>
<div id="accordion<?php echo $accordion; ?>">
<?php while ( have_rows('_accordion_zeile') ) : the_row(); $collapse++; ?>
<div class="card">
<div class="card-header" id="heading<?php echo $collapse; ?>">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse<?php echo $collapse; ?>" aria-expanded="true" aria-controls="collapse<?php echo $collapse; ?>">
<?php the_sub_field("_accordion_titel"); ?>
</button>
</h5>
</div>
<div id="collapse<?php echo $collapse; ?>" class="collapse" aria-labelledby="heading<?php echo $collapse; ?>" data-parent="#accordion<?php echo $accordion; ?>">
<div class="card-body">
<?php the_sub_field("_accordion_inhalt"); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
Okay guys, just made it a little bit less complicated now, no javascript needed. Just a ACF (modern) select field, added all my icons data like this:
...
<i class="icon-bucket">icon-bucket</i>
<i class="icon-gradient">icon-gradient</i>
<i class="icon-gradient2">icon-gradient2</i>
...
Only three for this example, of course there is a long, long list of more or less 800 icons … but loads super fast 🙂 . I then just load the css of my iconfont in my admin.css and put some tiny additional CSS and what I have now is a very nice icon-picker for my wordppress backend:
#ACFisawesome
@john: Any idea how to get this working? I load my backend.js with admin_enqueue_scripts
and try to add a class to alle the “select2-results__option” li elements – nothing happens.
$(document).ready(function){
$("#select2-acf-field_5a314116c7592-results li").addClass('myclasshere');
});
I am talking about the backend. I have a “Stylised UI” list and want to give the li elements the class to give them an icon.
I know I could do this with javascript/jQuery but maybe there is a filter or semething similar … ?
Thanks, but it’s not urgent.
I use it more than radio buttons, just looks much better.
Let’s imagine I have 4 columns with text/content. After a week I want to delete the last two columns – with this approach I have to delete all colunms and start a new row with 2 columns, right?
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!
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.