0

This is basic query arguments .

$loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1));

Now I want to pass custom arguments like 1.If it is front page post_type will be "post" and post per page will be "4" I know how to do it is_front_page() {//do stuff here} .But I want to inject the condition like this way

 $loop = new WP_Query(array('post_type' => 'is_front_page() {//do stuff here}', 'posts_per_page' => -1));

Can I do it?

  • Why? You can run the condition before the query and simply insert the output. – s_ha_dum May 14 '14 at 4:10
  • Thank you .I know that but thought a bit strange .. – ashraf May 14 '14 at 6:15
0

That can't be done, since its translated to sql query I don't see that code executing any where. You'll have to do what @s_ha_dum said.

Do it the other way, its cleaner and readable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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