Home Forums General Issues Flexible content Inception Reply To: Flexible content Inception

  • Update. I know where/when the infinite loop occurs.
    Now, I need to find how to solve it (and I’ve not yet found).

    Here’s an extract of my code:

    function taz_get_field_data($shortcodeID){
    	if (class_exists('acf')){
    		$layouts = get_field('taz_features', false, true);
    		return $layouts[$shortcodeID - 1];
    	} else {
    		error_log("taz_get_field_data(): ACF Plugin is not available.");
    		return null;
    function taz_features($atts, $content = null){
    	$a = shortcode_atts(array(
    		'id' => null
    		), $atts);
    	$shortcodeID	= (int)$a['id'];
    	$rowData	= taz_get_field_data($shortcodeID);
    	switch ($rowData['acf_fc_layout']){
    		case 'gallery':
    		case 'carousel':
    add_shortcode('taz_features', 'taz_features');

    Line 3 of the above code, we have: $layouts = get_field(‘taz_features’, false, true);
    When the last parameter is set to true, looks like the shortcode [taz_features id=4] is executed, thus entering again my shortcode function (taz_features), which will run taz_get_field_data(), which run get_field() again, and so on, thus generating the loop 🙁

    Setting false to the format value could solve my problem, but it would imply massive modifications of the rest of my code. I’d definitely like to avoid this.