ap_update_answers_count( integer $question_id, integer $counts = false, true|string $update_time = true )

Description #

Update count of answers in post meta.

Parameters #

  • $question_id
    integer (Required) Question ID.
  • $counts
    integer (Optional) Custom count value to update. Default value: false
  • $update_time
    true | string (Optional) Update time. Default value: true

Changelog #

VersionDescription
3.1.0Introduced.

Source #

File: includes/qameta.php

function ap_update_answers_count( $question_id, $counts = false, $update_time = true ) {
	if ( false === $counts ) {
		$counts = ap_count_published_answers( $question_id );
	}

	$args = array( 'answers' => $counts );

	if ( $update_time ) {
		$args['last_updated'] = current_time( 'mysql' );
	}

	return ap_insert_qameta( $question_id, $args );
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment