1

I have been trying like crazy to get comments turned on in a directory theme with Custom post types. Their support wont do much of anything but link me here and I've tried what I've found, but its still not working.

Could anyone shed light on this for me? I'll even pay someone a few bucks if they can help me get this working.

This is my current Functions.php code down to the end of the comments section:

function cs_comment_tut_fields() {

    $you_may_use = __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'Awaken' );
    $cs_comment_opt_array = array(
        'std' => '',
        'id' => '',
        'classes' => 'commenttextarea',
        'extra_atr' => ' rows="55" cols="15"',
        'cust_id' => 'comment_mes',
        'cust_name' => 'comment',
        'return' => true,
        'required' => false
    );
    $req = isset( $req ) ? $req : '';
    $html = '<p class="comment-form-comment fullwidt">' .
            '' . __( '', 'dir' ) . '' . ( $req ? __( '', 'dir' ) : '' ) . '' .
            '<label>
                    <i class="icon-comments-o"></i>
                    <textarea id="comment_mes" placeholder="' . __( 'Message', 'dir' ) . '" name="comment"  class="commenttextarea" rows="55" cols="15"></textarea>' .
            '</label>
                </p>';
    echo force_balance_tags( $html );
}

function cs_filter_comment_form_field_comment( $field ) {
    return '';
}

// add the filter
add_filter( 'comment_form_field_comment', 'cs_filter_comment_form_field_comment', 10, 1 );
add_action( 'comment_form_logged_in_after', 'cs_comment_tut_fields' );
add_action( 'comment_form_after_fields', 'cs_comment_tut_fields' );

remove_filter( 'the_title_rss', 'strip_tags' );
require_once ABSPATH . '/wp-admin/includes/file.php';

function switch_on_comments_automatically(){
    global $wpdb;
    $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open'")); // Switch comments on automatically
} 

function default_comments_on( $data ) {
    if( $data['post_type'] == 'directory' ) {
        $data['comment_status'] = 'open';
    }

    return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_on' );
  • A custom post type needs to support comments in order for it to work. Check out the codex here: codex.wordpress.org/Function_Reference/post_type_supports So it's likely the CPT you have set up hasn't got them added to the "supports" argument for setting up. – Richard Webster Feb 27 '17 at 20:35
  • It could be also that they are not using the comment request in the single-cpt.php file if it is using a separate file. – rudtek Feb 27 '17 at 22:42
  • Yeah, I'm not a programmer at all so I'm trying to make sense of the comments here. :) – ElectricCrow Feb 27 '17 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.