• I added a Recent News section to my Home page (a list of blogs), but it showed the oldest blog posts, not the newest ones.

    I managed to solve this by adding an orderby argument. Here are the first 40 lines of the modified blog.php file, with added content in bold:

    <?php
    if ( ! get_theme_mod( 'pure_portfolio_enable_blog_section', false ) ) {
    	return;
    }
    $content_ids  = array();
    $content_type = get_theme_mod( 'pure_portfolio_blog_content_type', 'post' );
    if ( $content_type === 'post' ) {
    	for ( $i = 1; $i <= 10; $i++ ) {
    		$content_ids[] = get_theme_mod( 'pure_portfolio_blog_content_post_' . $i );
    	}
    	$args = array(
    		'post_type'           => $content_type,
    		'post__in'            => array_filter( $content_ids ),
    		'orderby'             => 'post__in',
    		'posts_per_page'      => absint( 10 ),
    		'ignore_sticky_posts' => true,
    		'orderby'   => array(
    			'date' =>'DESC',
    			'menu_order'=>'ASC',
    			/*Other params*/
    		),
    	);
    } else {
    	$cat_content_id = get_theme_mod( 'pure_portfolio_blog_content_category' );
    	$args           = array(
    		'cat'            => $cat_content_id,
    		'posts_per_page' => absint( 10 ),
    		'orderby'   => array(
    			'date' =>'DESC',
    			'menu_order'=>'ASC',
    			/*Other params*/
    		),
    	);
    }

The topic ‘Suggestion for blog.php’ is closed to new replies.