I had no idea it was not possible to use if else statement inside an array in php. I've searched stackoverflow and found that shorthand version should actually work fine.
I tried it but still have errors and page doesn't load, my code:
query_posts (array(
($prefooter_order_logic == 'xviews' ? "'v_sortby' => 'views', 'v_orderby' => 'desc'," : "")
'order' => 'DESC',
'orderby' => $prefooter_order_logic,
'posts_per_page' => '10',
'post_type' => 'post',
'category_name' => $prefooter_category_select
));
This doesn't give me error:
but it doesn't work...
($prefooter_order_logic == 'xviews' ? "
'v_sortby' => 'views',
'v_orderby' => 'desc',
" : "
'order' => 'DESC',
'orderby' => $prefooter_order_logic,
"),
I've decided to stop playing around and do it easiest way:
btw, any thoughts if this is the best way to do it? or not?
if ($prefooter_order_logic == 'xviews') {
query_posts (array(
'v_sortby' => 'views',
'v_orderby' => 'desc',
'posts_per_page' => '10',
'post_type' => 'post',
'category_name' => $prefooter_category_select
));
} else {
query_posts (array(
'order' => 'DESC',
'orderby' => $prefooter_order_logic,
'posts_per_page' => '10',
'post_type' => 'post',
'category_name' => $prefooter_category_select
));
}