Question

I'm having a hard time implementing this into my theme. Right now the theme only displays the recent posts. I know how to display the recent post or pages however I don't know how to display both of them.

Here is the current loop code:

$nr_posts = ($sd_data['home_sidebar_hide'] == 1) ? $sd_data['home_news_posts_disabled'] : $sd_data['home_news_posts'] ;
$i = 0;
$args = array('post_type' => 'post',
                'posts_per_page' => $nr_posts,
                'order'          => 'DESC',
                'orderby'        => 'date',
                'post_status'    => 'publish'
            );
query_posts( $args );
if( have_posts() ) : while ( have_posts() ) : the_post(); $i++;
$margin_nr = ($sd_data['home_sidebar_hide'] == 1) ? 5 : 4; 
if( $i == 1) {
$class = 'span3 alpha';
} else if( $i == $margin_nr) {
$i = 0;
$i++;
$class = 'span3 alpha';
} else $class = 'span3';

?>
<div class="<?php echo $class; ?>">
<div class="news-item">
<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) : ?>
<?php the_post_thumbnail('recent-blog'); ?>
<?php endif; ?>
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a></h3>
<p><?php echo substr(get_the_excerpt(), 0, 50); ?>...</p>
<div class="news-meta clearfix"> <span class="news-date">
<?php the_time(get_option('date_format')); ?>
</span> <span class="news-comments">
<?php comments_popup_link( '0', '1', '%', 'comments-link', 'c'); ?>
</span> <span class="news-rating"><?php echo sd_post_like_link(get_the_ID()); ?></span>         </div>
</div>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
Was it helpful?

Solution

CHANGE

$args = array('post_type' => 'post',
                'posts_per_page' => $nr_posts,
                'order'          => 'DESC',
                'orderby'        => 'date',
                'post_status'    => 'publish'
            );

To

$args = array('post_type' => array('post','page'),
                'posts_per_page' => $nr_posts,
                'order'          => 'DESC',
                'orderby'        => 'date',
                'post_status'    => 'publish'
            );

Refer here for more WP QUERY

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top