Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1474942

    Hi team,
    I’ve an issue with comment zone / block element when this element are calling in an alb_custom_layout element :

    • If the comments element are calling directly on my page, it work perfectly : the comments are displaying and you can answer
    • If the comments element are calling in an alb_custom_layout element, it don’t work correctly : the comments are displaying but the reply is closed

    What’s wrong with it?

    Thanks by adavance for your help!
    Regards,
    Marc

    • This topic was modified 2 days, 18 hours ago by Octopus4444.
    #1475048

    Hey Octopus4444,

    Thank you for the inquiry.

    The alb_custom_layout post type does not support comments by default. Adding this filter to the functions.php file might help:

    
    add_filter('avf_custom_layout_cpt_args', 'avf_custom_layout_cpt_args_mod');
    
    /**
     * Callback function to modify arguments of Custom Layout CPT.
     *
     * @param array $args Arguments for the custom post type.
     * @return array Modified arguments with comments support.
     */
    function avf_custom_layout_cpt_args_mod($args) {
        if (isset($args['supports']) && is_array($args['supports'])) {
            $args['supports'][] = 'comments';
        }
    
        return $args;
    }
    

    Best regards,
    Ismael

    #1475053

    Hi Ismael,
    Thank you for taking the time to find a solution to my issue!

    Unfortunately, the problem is not resolved:
    I have indeed added the filter to the functions.php of my child theme as you instructed, and it correctly activates the comment options for the alb_customs_layout. So, I enabled comments for all my alb_customs_layout, but the comments are still closed on my page from the visitor’s side!

    You can see it for yourself with the private access I gave you (check the “Page B”).

    Thanks again for your help and research!
    Regards,
    Marc

    #1475078

    Hi,

    Thank you for the update.

    Please try to include this filter in the functions.php file:

    function av_remove_parent_filters() {
    	remove_filter('comments_open', 'av_comments_on_builder_posts_required');
    }
    add_action( 'after_setup_theme', 'av_remove_parent_filters' );
    
    add_filter('comments_open', '__return_true', 9999);

    If the issue persists, you may need to temporarily avoid using the custom layout for the comments section.

    Best regards,
    Ismael

    #1475083

    Hi Ismael,
    Thank you again for your valuable help!

    The provided code partially fixes the issue: it does enable the comments, but it no longer takes into account the enable/disable comment settings in the page options. I asked ChatGPT to complete your solution, and I’m sharing it here:

    function av_remove_parent_filters() {
        // Remove the filter that disables comments on ALB pages
        remove_filter('comments_open', 'av_comments_on_builder_posts_required');
    }
    add_action('after_setup_theme', 'av_remove_parent_filters');
    
    add_filter('comments_open', 'custom_comments_open_check', 9999, 2);
    
    /**
     * Check if comments are enabled for the current post.
     *
     * @param bool $open Whether comments are open.
     * @param int $post_id The ID of the current post.
     * @return bool Returns true if comments are enabled, false otherwise.
     */
    function custom_comments_open_check($open, $post_id) {
        // Check if the post type supports comments
        if (!post_type_supports(get_post_type($post_id), 'comments')) {
            return false;
        }
    
        // Check if comments are enabled for this specific post
        if ('open' === get_post_meta($post_id, '_comments_status', true)) {
            return true;
        }
    
        return $open;
    }

    It’s work for for me!
    Thanks again for your time and assistance,
    You can close this ticket as it is now resolved.
    Best regards,
    Marc

    #1475103

    Hi,

    Great, I’m glad that you found a solution and thanks for sharing. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Issue with alb_custom_layout and comments zone’ is closed to new replies.