Shorthand "if" - nice and clean casperel :)
Versiune printabilă
Shorthand "if" - nice and clean casperel :)
@maskatu: cu placere
@haos: "nice and clean" - datorita acestui lucru ar trebui sa-l foloseasca mai multi oameni (atunci cand e posibil). Cand vad cod de genul celui de mai jos... ma apuca groaza.
Cod PHP:if($var_x == 1){
$var_y = 'test';
}else{
$var_y = 'test2';
}
@casperel - cred ca tine de o anumita obisnuinta. uneori ma intrebam si eu de ce nu-l folosesc mai des :)
@casperel, mai ajuta-ma te rog cu asta ca nu-i dau de cap nicicum:
Codul e asta iar linia 42 este prima din cod:Cod HTML:Undefined variable: featured_posts on line 42 of /wp-content/themes/mytestheme/index.php
Daca e nevoie sunt dispus sa platesc.Cod:if ( !is_object( $featured_posts ) || !$featured_posts->have_posts() ) {
// Try another query
$featured_posts = new WP_Query(array(
'post_type' => $post_types,
'showposts' => 3,
'tag' => get_option('tigu_featured_tags')
));
}
Multumesc.
Din cate imi aduc aminte (si sper sa am dreptate)... daca nu exista rezultate, wp_query nu returneaza nimic, asa ca urmatoarea modificare ar avea sens.
Cod PHP:if ( empty($featured_posts) ) {
// Try another query
$featured_posts = new WP_Query(array(
'post_type' => $post_types,
'showposts' => 3,
'tag' => get_option('tigu_featured_tags')
));
}
Parfum! ;)
Merci!