• Hello everyone.

    My website blog page is this – https://decoratethetable.com/blog/

    The problem is, it’s only showing my latest posts. My theme doesn’t have an option for this, so is there a way I can make this blog page show blog posts that I put up only, rather than showing my latest posts.

    Basically, I want to add 1 or two posts a week to this page, separate from the main site.

    Thanks

    Alex

Viewing 3 replies - 1 through 3 (of 3 total)
  • Firstly, create a new category into which you can tag your handpicked posts.
    Next create a custom page template. Simply loop your new category in it. Create a new page of the template.
    Now set the new page as homepage by going to dashboard-settings-reading.

    Alternatively, instead of using a custom page template, just name the file home-page.php and save it within your theme folder. This will override your current homepage.

    PS: Please take backups and use child theme to work.

    Thread Starter weirdali

    (@weirdali)

    Hi thanks for your reply!

    I think you may have misunderstood however ?? I want to keep the homapge as it now, which can be found at https://www.decoratethetable.com

    I want the blog page to be separate and not feature any of the website content… Does that make sense?

    Sorry if you knew that maybe I just didn’t understand your answer.

    Thanks!

    Alex

    Ok sorry i think i was a bit abstract.

    Am assuming that you currently have 2 separate pages created – one for homepage and other for blog. And these you have set via dashboard->settings->reading.

    now the default page template is usually set to display latest blog posts. for example in twentyfourteen, page.php contains:

    get_header(); ?>
    
    <div id="main-content" class="main-content">
    
    <?php
    	if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
    		// Include the featured content template.
    		get_template_part( 'featured-content' );
    	}
    ?>
    	<div id="primary" class="content-area">
    		<div id="content" class="site-content" role="main">
    
    			<?php
    				// Start the Loop.
    				while ( have_posts() ) : the_post();
    
    					// Include the page content template.
    					get_template_part( 'content', 'page' );
    
    					// If comments are open or we have at least one comment, load up the comment template.
    					if ( comments_open() || get_comments_number() ) {
    						comments_template();
    					}
    				endwhile;
    			?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    	<?php get_sidebar( 'content' ); ?>
    </div><!-- #main-content -->
    
    <?php
    get_sidebar();
    get_footer();

    but since you want it to show only your selected posts, we need to alter this loop. and it is advised to NOT alter this files code. instead make a separate page template for the job. for example, create a new file named say template-blog.php and place it within your theme folder. ensure the file is in UTF8 encoding. now place this code into file:

    <?php
    /**
    Template Name: Blogpage
    **/
    get_header(); ?>
    
    <div id="main-content" class="main-content">
    	<div id="primary" class="content-area">
    		<div id="content" class="site-content" role="main">
    
    <?php
    $args = array( 'numberposts' => 10, 'category' => 1 );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post);
    the_title(); the_excerpt();
    endforeach; ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    	<?php get_sidebar( 'content' ); ?>
    </div><!-- #main-content -->
    
    <?php
    get_sidebar();
    get_footer();

    **i havent tested the code**
    so well what i have done here is to retain the main page structure. but the loop within is altered to loop the category with ID ‘1’ and show 10 posts.

    so now if you save this and create a new page on your website and use this template (Blogpage), it will show the loop of 10 from category 1.

    now back to what you asked.. you need hand-picked posts to be shown right? for this, you create a new category, say ‘myfavs’. now add the posts which you want to this category. note its ID. now edit your template-page.php file to use myfavs category ID.
    save, reload, and it should work. note that sometimes you will need to switch to another theme and switch back to your theme for templates to work and see the changes. also flush cache and put CDN on dev if you have.

    also if you noticed, the template is an open playground.. do whatever you want there. just mention Template Name: at the beginning, thats all WP wants.

    ofcourse, i assume you know coding. pls take backups and work on child theme, etc. code safe.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with Blog page!’ is closed to new replies.