Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Elementor插件和自定义查询难度,按Wordpress中大多数视图/流行帖子排序_Php_Wordpress_Plugins_Elementor_Jetpack - Fatal编程技术网

Php 使用Elementor插件和自定义查询难度,按Wordpress中大多数视图/流行帖子排序

Php 使用Elementor插件和自定义查询难度,按Wordpress中大多数视图/流行帖子排序,php,wordpress,plugins,elementor,jetpack,Php,Wordpress,Plugins,Elementor,Jetpack,我有以下代码: // Posts or Portfolio Widget add_action( 'elementor/query/my_custom_filter', function( $query ) { // Modify the posts query here } ); 资料来源: 需要调用my_custom_filter查询以按以下方式排序: get_option( 'stats_cache' ); 这将类似于: array( ['7375996b7a989f9

我有以下代码:

// Posts or Portfolio Widget
add_action( 'elementor/query/my_custom_filter', function( $query ) {
    // Modify the posts query here
} );
资料来源:

需要调用my_custom_filter查询以按以下方式排序:

get_option( 'stats_cache' );
这将类似于:

array(
    ['7375996b7a989f95a6ed03ca7c899b1f'] => array(
        [1353440532] => array(
            [0] => array(
                ['post_id'] => 0
                ['post_title'] => 'Home page'
                ['post_permalink'] => 'http://www.example.com/'
                ['views'] => 1132
            )
            [1] => array(
                ['post_id'] => 4784
                ['post_title'] => 'Hello World!'
                ['post_permalink'] => 
                ['views'] => 493
            )
            /* till item [9] */
或者这个(我在wp上托管并运行jetpack——实际上这是首选):

这将返回以下内容:

array(
    [0] => array(
        ['post_id'] => 0
        ['post_title'] => 'Home page'
        ['post_permalink'] => 'http://www.example.com/'
        ['views'] => 6806
    )
    [1] => array(
        ['post_id'] => 8005
        ['post_title'] => 'Hello World!'
        ['post_permalink'] => 
        ['views'] => 1845
    )           
    /* till item [29] */
资料来源:

我已经创建了自定义查询ID-

( 'elementor/query/my_custom_filter', function( $query )
但我不知道如何使用这两个功能:

  • get_选项('stats_cache')
  • 如果(函数_存在('stats_get_csv')){ $top_posts=stats_get_csv('postview','period=month&limit=30'); }
  • 或在此处插入它们的位置/方式:

    // Posts or Portfolio Widget
    add_action( 'elementor/query/my_custom_filter', function( $query ) {
        // Modify the posts query here
    } );
    
    以使查询正常工作

    我尝试将jetpack函数粘贴到内部,但没有成功,我尝试了
    'orderby'、$top_posts
    或调用
    $top_posts=$query
    ,但没有成功,其他一些东西也没有起作用,当然这里没有做任何事情

    // Posts or Portfolio Widget
    add_action( 'elementor/query/my_custom_filter', function( $query ) {
        // Modify the posts query here
    } );