最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - SEARCH QUERY PLEASE HELP | call_user_func_array() expects parameter 1 to be a valid callback php

programmeradmin0浏览0评论

Major issue with my search queries being outputted incorrectly on the blog page with respect to query's. In wordpress admin most relevant listed first but outputted DESC on page.

I have this code in funtions,php

function change_posts_order( $query ) {
if ( $query-is_home() && $query-is_main_query() ) {
$query-set( 'orderby', 'title' );
$query-set( 'order', 'ASC' );
}
}

add_action( 'pre_get_posts', ' change_posts_order ' );

Bt it does not work - I have removed all plugins on page except jetpack and akismet: Still no joy. PhP returns these related errors:

please help if you can

Major issue with my search queries being outputted incorrectly on the blog page with respect to query's. In wordpress admin most relevant listed first but outputted DESC on page.

I have this code in funtions,php

function change_posts_order( $query ) {
if ( $query-is_home() && $query-is_main_query() ) {
$query-set( 'orderby', 'title' );
$query-set( 'order', 'ASC' );
}
}

add_action( 'pre_get_posts', ' change_posts_order ' );

Bt it does not work - I have removed all plugins on page except jetpack and akismet: Still no joy. PhP returns these related errors:

please help if you can

Share Improve this question edited Oct 13, 2019 at 8:32 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Oct 12, 2019 at 9:19 Tom ConnellTom Connell 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You have extra spaces around change_posts_order, inside the quotes:

add_action( 'pre_get_posts', ' change_posts_order ' );

PHP can’t find a function with that name, because wits looking for that function preceded with the spaces. Remove the spaces to fix the issue:

add_action( 'pre_get_posts', 'change_posts_order' );
发布评论

评论列表(0)

  1. 暂无评论