Support

Account

Home Forums General Issues Issues with ACF fields on WP comment template

Unread

Issues with ACF fields on WP comment template

  • Hello 🙂

    I’m having problems with the displaying of ACF fields on a given comment template.
    Specifically on the page.php and/or a custom template called page-grid.php

    I have two custom comment templates registered via the functions.php –

        function my_news_comment_template( $comment, $args, $depth ) {
    
            <?php if( get_field('image_test', $comment) ): ?>
    
                <img src="<?php the_field('image_test', $comment); ?>" />
    
            <?php endif; ?>
    
                ... etc
        }
    
        function my_gridpage_comment_template( $comment, $args, $depth ) {
    
            <?php if( get_field('image_test', $comment) ): ?>
    
                <img src="<?php the_field('image_test', $comment); ?>" />
    
            <?php endif; ?>
    
            ... etc
        }
    

    in comments.php –

    if a post:

        wp_list_comments( array(
            'style'       => 'ol',
            'short_ping'  => true,
            'avatar_size' => 74,
            'callback'	  => 'my_news_comment_template' 
        ) );
        
    

    if a page (grid template):

     wp_list_comments( array(
            'style'       => 'ol',
            'short_ping'  => true,
            'avatar_size' => 74,
            'callback'	  => 'my_gridpage_comment_template'
        ) );
    

    ACF Setup –

    Fields are registered/configured via the WP CMS and rules set accordingly. Two field groups:

    – One field group, assigned to display if a single post of a custom post type called “News”. This works completely as expected! 🙂
    – The other field group, assigned to display if the page template is called “page-grid”. This is the one that I’m having problems with.

    Notes:

    – As far as I’m aware I’m not experiencing any PHP errors anywhere (or JS for that matter).
    – On both comment forms it ALWAYS loads the normal WP comments form as expected, there are just no ACF fields. Suggesting the appropriate WP settings are correct, as its allowing the form to exist/load/submit etc?
    – My (self created) WP theme runs on Barba.js, and plugins include: “ACF Pro – Version 5.8.12 ” and the “ACF to REST API”. As far as I’m aware No other plugin could affect this issue. others Plugins used are “WP Sync DB”, “WP Sync DB Media Files” and “JWT Authentication for WP-API”.
    – WordPress 5.4.2
    – Hosting via Cloudways.

    I’ve tried:

    – Ensuring that comments are open & and all WP settings are configured correctly.
    – Disabling the “news” comment form (having only one registered via php). Makes no difference.
    – Removing other ACF field groups and other PHP content on the page. Makes no differences.
    – I also use the “ACF to REST API” plugin on the grid page template. Disabling this plugin makes no difference.
    – Setting the ACF CMS / Display rules to allow the “grid page” field group to display on any “page”, or other specific page name/id’s. Makes no difference. i.e it seems it just doesn’t load on pages?
    – A lot of googling / stack overflow, but I didn’t find many other references / code examples.

    – I have loaded the “grid page” field group and comment form on my news posts – which works! Suggesting its not the WP and ACF settings, my markup or PHP functions that are incorrect?

    I’m not sure what else I can try at this stage, or maybe what I have overlooked – I’m hoping I’ve made some sort of stupid mistake here?!

    I can PM WP credentials for my staging site and the code lives on Github.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.