Support

Account

Home Forums General Issues If post is over 100 views it wont show in query

Helping

If post is over 100 views it wont show in query

  • Hi,

    I have a custom field “count_view”, updated every page load.

    However, when a post gets over 100 views it disappears from query?

    add_action( 'elementor/query/most_popular_filter', function( $query ) {
    	$query->set( 'orderby', 'meta_value' );
    	$query->set( 'meta_key', 'count_view' );
    	$query->set( 'order', 'DESC' );
    } );
    function child_theme_head_script() {
    	if (is_singular('post')) {
    		$views = get_field('count_view');
    		$views++;
    		update_field('count_view',$views);
    	}
    }
    add_action( 'wp_head', 'child_theme_head_script' );
  • try

    
    $query->set( 'orderby', 'meta_value_num' );
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘If post is over 100 views it wont show in query’ is closed to new replies.