<?php
if ( is_home() ) {
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<div id="post">
<?php the_content(); ?>
</div>
<?php endwhile;?>
<?php endif; ?>
} else if (is_page() ) {
$category = get_post_meta($posts[0]->ID, 'category', true);
}
if ($category) {
$cat = get_cat_ID($category);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = 4; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => array($cat),
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'caller_get_posts' => $do_not_show_stickies
);
$temp = $wp_query; // assign orginal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if( have_posts() ) :
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div id="post">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php endif;
$wp_query = $temp;
}
?>
<?php if ( is_home() ) { <?php if ( have_posts() ) : while (
Share
On line #4 you are opening a new PHP block even though the old one hasn’t been closed yet.
You’ll want to delete the preceding
<?phpon that line. You don’t need it.Additionally:
You have an extra
endwhile;in yourelseblock. The while loop is started and closed within theif ( is_home() ) {block.The code starting with
} else if (is_page() ) {is not in a PHP block. You should either open a<?phpblock or not close the preceding one.