I need to formulate this code to respond to the requirements of a specific category where within it the posts will be presented in a random way. For this I made this code in category.php
of the Storyline template.
if(is_category(48)){
$args = array(
'cat' => 48,
'orderby' => 'rand'
);
$cp = new WP_Query($args);
} else {
if(of_get_option('order-posts') == "ll" ){
global $query_string;
query_posts( $query_string . '&order=ASC' );
}
}
..., condition that is already working but need to apply the following condition in another part of the code and does not appear error, simply does not execute:
if(is_category(48)){
if(have_posts()) : while ( have_posts() ) : the_post();
} else {
if($cp->have_posts()) : while ( $cp->have_posts() ) : $cp->the_post();
}
This code allows the 48 category to apply a 'orderby'='rand'
. In short, what I need is to make this if/else
work.
The difference between ifs
is that the second applies conditions of new WP_Query that the former does not apply.