WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get a Page to display a custom query using the snippet posted here. The following is in my functions.php:

function alter_the_query($request) {
    $dummy_query = new WP_Query();  // the query isn't run if we don't pass any query vars
    // this is the actual manipulation; do whatever you need here
    if($dummy_query->is_page('blog')) $request['category_name'] = 'Blog';
    // and then
    return $request;

The page called "Blog" has a basic loop inside- so it should be displaying whatever WP_Query tells it to. However, it is only displaying the Page content- which should have been ignored.

I can't seem to find a reference that explains the properties of the $request object, so I'm not sure what I should do to make this snippet work. Any ideas?

share|improve this question
According to your code, you are trying to display posts that are in the category "Blog", is that correct? – Manny Fleurmond Aug 29 '11 at 6:42

Inside your function, simply do a var_dump of the $request object to reveal its properties.

share|improve this answer
Thanks, I updated the question name to elicit suggestions about how to actually make the function work. But incidentally, what's a safe way to echo the results of the var_dump? – Isaac Lubow Jul 27 '11 at 4:40
yeah...wasn't sure this was too helpful, but this would be a good step to get started. The var_dump would just allow you to see the props of the object. Just dump it once to see what's in the object. Then work from there. This is more of a troubleshooting step than a full solution. – tollmanz Jul 27 '11 at 4:46
If I do $vardump = var_dump($request); in the function, echoing $vardump on the page yields nothing. How can I check this value? – Isaac Lubow Jul 27 '11 at 8:01
var_dump just prints to screen, it doesn't return anything. If you wanted to inspect the request inside a variable you'd have to use var_export - ie, $vardump = var_export( $request, true ); – goldenapples Mar 11 '12 at 22:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.