I'm developing a site that uses a Artist custom post type and I need to query all posts of this type in a page template. I need to set the is_post_type_archive property to true too to filter this query using the posts_orderby filter. I'm using the following code, but it seems WordPress is ignoring the third line:
$args = array('post_type' => 'artist');
$wp_query = new WP_Query( array_merge( $args, array('nopaging' => true) ) );
$wp_query->is_post_type_archive = true;
This is the filter:
function artist_posts_orderby( $orderby )
{
if (is_post_type_archive('artist')) {
$orderby = "RIGHT(post_title, LOCATE(' ', REVERSE(post_title)) - 1) ASC";
}
return $orderby;
}
add_filter('posts_orderby', 'artist_posts_orderby' );
Any ideas?
Thanks in advance