1
I need to formulate this code to respond to the requirements of a specific category where within it the posts will be presented randomly. For that I made this code on category.php
of the template Storyline.
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 no error appears, simply does not perform:
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 in the category 48 i apply a 'orderby'='rand'
. In short, what I need is to get this if/else
work.
The difference between the ifs
is that the second applies conditions of new Wp_query that the former does not apply.
What template are you using this code on? That
global $ha
has something to do with the problem? What error does it make when running?– brasofilo
The
global $ha
is not related to the problem presented. I am using Category.php of the template Storyline. No error appears, simply does not execute.– Marcos Vinicius