WordPress.org

Ready to get started?Download WordPress

Forums

Reading Posts (7 posts)

  1. cecev
    Member
    Posted 1 year ago #

    I have a wierd problem...or maybe I'm doing something wrong that I can't see.

    This is what I want.
    The first page (home) of my blog to display the latest blog in full text.
    Another page will display last 10 posts, not the home page.

    I have the setting in Reading:
    Front Page to display latest posts
    Blog page to display 1 in full text.

    What is happening now:
    The front page displays blog posts in summary with a Read More link.

    How can I make sure that the hoome page (front page) displays the latest posts in full text and blog page to display summary of 10 posts.

    Thanks for any help.

  2. hotwebideas
    Member
    Posted 1 year ago #

    You may need a plugin to handle this, but try turning off your summary in your reading settings and you may need a custom loop to display the next 10 blog posts and exclude the latest, which you said would display as a full post.

    After you turn off the summary settings, there should be a setting for how many posts you want to show and you would set that to 1, so only your latest blog post is showing.

    To show your next 10 posts, you would probably need a custom loop in your WordPress theme with this code:

    <?php
    $posts = new WP_Query(array(
    	'posts_per_page'	=> 10,
    	'offset'		=> 1
    	)); 
    
    	while ( $posts->have_posts() ) : $posts->the_post();
    		$title			= get_the_title();
    		$content		= get_the_content();
    		$id				= get_the_ID();
    		echo ("
    			<div style=' width:90%; background:none; font-size:.80em; text-align:left; padding:10px 0 10px; border-bottom:1px solid #CCC; '>
    			<h5 style='display:inline; font-size:.90em; padding-left:0px; color:#4da56b;'>$title</h5><br/>
    			<div style=' color:#777777; font-size:.75em;' >$content</div>
    			</div>
    		");
    	endwhile;
    
    ?>

    Bruce
    LatestBlogPosts.com

  3. cecev
    Member
    Posted 1 year ago #

    Hi Bruce,

    Thanks for your response. And I'll try your script.

    However, the real mystery for me is...

    Not being able to post the latest post on the home page in its full text. I know my settings are correct. I have the same setting on my localhost, and it works with the full text. The production site doesn't.

    Have any clue why?

  4. hotwebideas
    Member
    Posted 1 year ago #

    Hey cecev, I am going to give you some code for this. This may seem like a lot of steps if you are not a programmer, so if I am making this seem to difficult, maybe someone else reading this can help, but I assure you that this will work. I did something almost like this 2 days ago, so it is still fresh in my mind.

    1. Create a new page template (notice I said page template and not a page). Let's title it "Latest Blog Post" since that is what your result would be. You would need to turn this page into a template like this:
      /*
      Template Name: Latest Blog Posts
      */

      Name the page "latest.php" and add (upload) it to your theme folder.

    2. Add this code, which is the WordPress main loop function query_posts():
      <?php
      $posts = new WP_Query(array(
      	'posts_per_page'	=> 1,
      	'orderby' => ID,
      	'order' => 'DESC'
      	)); 
      
      	while ( $posts->have_posts() ) : $posts->the_post();
      		$title			= get_the_title();
      		$content		= get_the_content();
      		$id				= get_the_ID();
      		echo ("
      			<div style=' width:90%; background:none; font-size:.80em; text-align:left; padding:10px 0 10px; border-bottom:1px solid #CCC; '>
      			<h5 style='display:inline; font-size:.90em; padding-left:0px; color:#4da56b;'>$title</h5><br/>
      			<div style=' color:#777777; font-size:.75em;' >$content</div>
      			</div>
      		");
      	endwhile;
      
      ?>

      What you are doing here is telling WordPress to order all of your posts by the ID number in descending order and then return only 1 post. That will always be your latest blog post.

    3. This will be your page template. Now, go into your WP-ADMIN and add a new page. Title is "Latest Blog Post", because that is what the result will be. Notice now, that you have a pull down menu called "Template" since you created the template in the last step. Select the one titled "Latest Blog Posts" and save the page. Now you will see your latest blog post with its full content.
    4. Finally, yup your last step. Yay! Go into your settings in WP-Admin and select Writing. Then, make that Latest Blog Post page your default.

    Those steps will work. I hope it does not sound like a lot of work, but it would take me only 10 minutes for all this. If you are new to WordPress programming, it would take you longer, but if anyone else can offer a quicker solution, please do.

    Either way, cecev, give this a shot and let me know how it works.

    Bruce

  5. cecev
    Member
    Posted 1 year ago #

    Hey Brian,

    It works. However the style doesn't work with the rest of the site.
    I tried to put the code from page.php to apply the style, but that didn't work either.

    Can you recommend a solution?

  6. hotwebideas
    Member
    Posted 1 year ago #

    Hey Thuy, you mean, Bruce, not Brian. LOL

    Glad it works. Can you please post your code here so I can look? When you say the style does not work, do you mean your CSS is not displaying? If so, are you calling the CSS file from the right place? Maybe you need to add <?php bloginfo('template_directory');?> before your .CSS file from your <Link> tag.

    Bruce

  7. cecev
    Member
    Posted 1 year ago #

    Hi Bruce,

    I apologize for calling you Brian.

    The good news is I solved it. Not sure where the problem was, but it worked find on localhost, so I just copy the entire WP files to a test site and it worked.

    Thanks for your help.

    PS Your script does work. I believe the script between echo just has to match the style on site. Thanks a million for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.