Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #775610

    Hello!
    I’m trying to add the builder to two custom post types with the code that I’ve found in some documentation (below)
    When i add it to one post type it works great BUT i need to add the builder to another post type (two in total) and if I duplicate the code (and change the post type name) it brakes the site.

    How can I add the builder to two post types?

    Thank you!

    //avia builder to custom type post

    add_filter('avf_builder_boxes', 'avia_register_meta_boxes', 10, 1); //Add meta boxes to custom post types
        function avia_register_meta_boxes($boxes)
        {
            if(!empty($boxes))
            {
                foreach($boxes as $key => $box)
                {
                        $boxes[$key]['page'][] = 'posttypename';
                }
            }
            return $boxes;
        }
    
    #775696

    Hi Gigi!

    When duplicating the code, are you also changing the function name, or you are using the same?

    Cheers!
    Basilis

    #775934

    Thank you Basilis for your quick repsonse 🕺
    Actually no… how can I do that? Here is the code that brakes the site

    //avia builder to residents
    
    add_filter('avf_builder_boxes', 'avia_register_meta_boxes', 10, 1); //Add meta boxes to custom post types
        function avia_register_meta_boxes($boxes)
        {
            if(!empty($boxes))
            {
                foreach($boxes as $key => $box)
                {
                        $boxes[$key]['page'][] = 'resident';
                }
            }
            return $boxes;
    }
    
    //avia builder to faculty
    
    add_filter('avf_builder_boxes', 'avia_register_meta_boxes', 10, 1); //Add meta boxes to custom post types
        function avia_register_meta_boxes($boxes)
        {
            if(!empty($boxes))
            {
                foreach($boxes as $key => $box)
                {
                        $boxes[$key]['page'][] = 'faculty';
                }
            }
            return $boxes;
    }

    Thank you!!

    #775978

    I have the same problem as above, and it seems, that the question about changing the function name is not answered??? I started at the documentation here, and read the article

    Could be great, if you would explain in that article, how to ad the code for two or more custom post types!

    #776410

    Hi,

    This is the function name:

    avia_register_meta_boxes

    , two functions cannot have the same name, that is likely why you are getting an error. Please change the one of the function names to something else.

    Best regards,
    Rikard

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.