Problem with add_filter function
-
Hi,
i was playing with add_filter to create a plugin that permit to list my posts in an mandatory order (date independent).
So, i’m adding this filter
add_filter(‘posts_join’, ‘wp_postorder_join’);
function wp_postorder_join() {
global $wpdb;
return ” LEFT JOIN ” . $wpdb->postmeta . ” as postorder on postorder.post_id = ” . $wpdb->posts . “.ID and postorder.meta_key = ‘post_order’ “;
}Everything works fine but when i try to list posts by taxonomy item, the join settep up by wordpress creating the query is replaced by my join and query runs in error.
I dont know if this is a bug or not but i have solved like this:
at wp-includes\query.php line 1185
$where = $where . apply_filters(‘posts_where’, $where);
$join = $join . apply_filters(‘posts_join’, $join);So, i can mantain original join and adding a custom join.
- The topic ‘Problem with add_filter function’ is closed to new replies.