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')代码>
// 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
} );