I am currently using this code in my theme right before showing the content of the custom post type my_post_type:
$title = $post->post_title;
query_posts( array (
'post_type' => 'page',
'posts_per_page' => -1,
'my_taxonomy' => $title
));
This means that when I go to .../my_post_type/some_title, I see all pages that are assigned "some_title" as my_taxonomy.
Now I want to do the same thing in a plugin in stead of a theme. This means is (I guess) that I have to use the "request" filter? I have tried to do this:
add_filter( 'request', 'alter_the_query' );
function alter_the_query( $request ) {
$request['post_type'] = 'page';
$request['my_taxonomy'] = 'some_title'; // just hardcoded so far while testing
$request['posts_per_page'] = -1;
return $request;
}
But it doen't return any pages at all. Not even this works:
add_filter( 'request', 'alter_the_query' );
function alter_the_query( $request ) {
$request['post_type'] = 'page';
return $request;
}
What am I doing wrong, or how can I achieve the same thing as my with my call to query_posts()?
Thanks a lot!