Tagged: alb custom layout, comments
-
AuthorPosts
-
January 10, 2025 at 5:15 pm #1474942January 13, 2025 at 6:30 am #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,
IsmaelJanuary 13, 2025 at 10:14 am #1475053Hi 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,
MarcJanuary 14, 2025 at 6:38 am #1475078Hi,
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,
IsmaelJanuary 14, 2025 at 10:38 am #1475083Hi 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,
MarcJanuary 14, 2025 at 8:24 pm #1475103Hi,
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 -
AuthorPosts
- The topic ‘Issue with alb_custom_layout and comments zone’ is closed to new replies.