Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #358273

    Hi to the team !

    A small question here ( I hope ^^; ). I am using the documentation’s snippet for using the Layout Builder with any post type and it’s working great :

    add_filter('avf_builder_boxes', 'add_builder_to_posttype');
    
    function add_builder_to_posttype($metabox)
    {
    	foreach($metabox as &$meta)
    	{
    		if($meta['id'] == 'avia_builder' || $meta['id'] == 'layout')
    		{
    			$meta['page'][] = 'post'; /*instead add the name of the custom post type here*/
    		}
    	}
    	
    
    	return $metabox;
    }

    But I have several Custom Post Types and I’m not sure how to “queue” all of them in snippet. I believe I have to use an array but I’m not sure how. Could you help me on this ?

    Thanks in advance ! Good day to the team !

    Fred

    #358570

    Hey FLQA!

    Try this out.

    add_filter('avf_builder_boxes', 'add_builder_to_posttype');
    
    function add_builder_to_posttype($metabox)
    {
    	foreach($metabox as &$meta)
    	{
    		if($meta['id'] == 'avia_builder' || $meta['id'] == 'layout')
    		{
    			$meta['page'][] = 'post'; 
                            $meta['page'][] = 'products'; 
                            $meta['page'][] = 'reviews'; 
                            $meta['page'][] = 'recipes'; 
    		}
    	}
    	
    
    	return $metabox;
    }

    Cheers!
    Elliott

    #358787

    Hi Elliott!

    Perfect, thanks a lot!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘ALB for several CPT – How to use an array?’ is closed to new replies.