Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1468812

    Hi,

    we have website that uses a customized template in the loop-index.php file for posts. When switching to ALB this template is no longer being used. I can’t figure out which template the builder is using instead. Is it possible to make the ALB also use the index-loop.php. Is there maybe a setting in the backend for it. Right now I tried using this code, but it doesn’t seem to work.

    function force_loop_index_template() {
        // Check if we're viewing a single post
        if ( is_single() ) {
    
            // Get the current post ID
            $post_id = get_the_ID();
    
            // Check if the Advanced Layout Builder is active for the current post
            $is_alb_active = get_post_meta( $post_id, '_aviaLayoutBuilder_active', true );
    
            // Check if the post belongs to the "Blog" or "News" category
            $has_required_category = has_category( array( 'Blog', 'News' ), $post_id );
    
            // If ALB is active and the post has the required categories
            if ( $is_alb_active == 'active' && $has_required_category ) {
                // Force load the loop-index.php template from the /includes/ folder in the child theme
                $custom_template = get_stylesheet_directory() . '/includes/loop-index.php';
    
                // Check if the template file exists
                if ( file_exists( $custom_template ) ) {
                    // Load the custom template and exit to stop further execution
                    include( $custom_template );
                    exit;
                }
            }
        }
    }
    add_action( 'template_redirect', 'force_loop_index_template', 999 );
    #1469060

    Hey emilconsor,

    Thank you for the inquiry.

    When the Advance Layout Builder (ALB) is active, it’s going to ignore the single.php and the loop-index.php file and use the template-builder.php file instead.

    Best regards,
    Ismael

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