ap_update_views_count( integer|false $post_id, integer|false $views = false )

Description #

Update views count of qameta.

Parameters #

  • $post_id
    integer | false (Required) Question ID.
  • $views
    integer | false (Optional) Passing view will replace existing value else increment existing. Default value: false

Changelog #

VersionDescription
3.1.0Introduced.

Source #

File: includes/qameta.php

function ap_update_views_count( $post_id, $views = false ) {
	if ( false === $views ) {
		$qameta = ap_get_qameta( $post_id );
		$views  = (int) $qameta->views + 1;
	}

	ap_insert_qameta( $post_id, array( 'views' => $views ) );
	return $views;
}

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