
-
AuthorPosts
-
October 10, 2024 at 3:03 pm #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 );
October 14, 2024 at 6:24 am #1469060Hey 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,
IsmaelApril 14, 2025 at 10:36 am #1481297Is there any way to force to use the alb per default, without the client-side-script which is provided in different threads?
April 14, 2025 at 1:10 pm #1481303Hi,
Yes, there is a filter in ..config-templatebuilderavia-template-builderphpclass-template-builder.php:
$force_alb = apply_filters( 'avf_force_alb_usage', false, $post );
Return anything different from false (e.g. true). This adds class ‘avia-force-alb’ to body.
If you need help with the filter let us know.
Best regards,
GünterApril 14, 2025 at 4:39 pm #1481315yes give more info about the filter and what it is meant for. And how to use it in the sense of “for a specific post”
April 15, 2025 at 5:43 am #1481355Hi,
An example can be found here: https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/ALB%20core/avf_force_alb_usage.php
Best regards,
IsmaelApril 15, 2025 at 12:38 pm #1481374thanks Ismael – and in that condition :
if( 'post' == $post->post_type )
we now have to choose the cpt – if we only like to influence that post
-
AuthorPosts
- You must be logged in to reply to this topic.