Thursday, 15 July 2010

php - Wordpress, meta_filter_posts damaged the custom-menu widgets -



php - Wordpress, meta_filter_posts damaged the custom-menu widgets -

when add together code functions.php

function meta_filter_posts( $query ) { if(is_tag() && is_main_query()) { $currenttagid = get_queried_object()->term_id; $query->set('orderby','meta_value_num'); $query->set('meta_key', 'rank_tag_'.$currenttagid.''); $query->set('order', 'asc'); } } add_filter( 'pre_get_posts', 'meta_filter_posts' );

my sidebar custom menu-widgets doesnt work anymore. the widgets show widget-title not widget-content.

the rest, e.g. text-widgets working normal.

but why? wrong code?

you have 2 problems here:

when using pre_get_posts, should create sure target front end end only. pre_get_posts alters type of queries front end end and backend

is_tag() , is_main_query() should fellow member variables of $query

you can this

if(!is_admin() && $query->is_tag() && $query->is_main_query())

php wordpress widget

No comments:

Post a Comment