• If anyone could help, I’d greatly appreciate it. I have a static front page. What I would like to do is have one category/post on the page update to latest entry. Is it possible to somehow make this happen? Thank you in advance. https://www.Wapatu.com

Viewing 10 replies - 1 through 10 (of 10 total)
  • You want to display your latest post on your home page, yes? It should be possible but it would need a custom page template. Does your current Home page use a custom template or just the default page template?

    If it’s the latter, see https://codex.www.ads-software.com/Pages#Creating_Your_Own_Page_Templates – especially the part about the template name at the top of the custom template. Make a copy of your theme’s page.php file and add a custom template name (something intuitive like “Home”) then save the new file as homepage.php.

    Next you need to decide where on the page you want your latest post to be shown – before or after the page content. Adding the new block of code before <?php if (have_posts()) : while (have_posts()) : the_post(); ?> will result in your latest post being shown at the very top of the home page. Adding the new block after <?php endwhile; endif; ?> will place near the bottom of the page.

    Once you decided on your preferred location, try adding:

    <?php
     $latest = get_posts('numberposts=1');
     foreach($latest as $post) :
        setup_postdata($post);
     ?>
    <div class="latest">
    <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
     <?php the_content(); ?>
    </div>
     <?php endforeach; ?>

    Save the file and make sure it’s placed in your current theme folder. Now it’s just a case of editing your Home page and selecting your new page template.

    https://codex.www.ads-software.com/Template_Tags/get_posts

    Thread Starter wapatu

    (@wapatu)

    Esmi, thank you for your response. I remember you. You’ve been a wonderful help to me before. Unfortunately, I still haven’t mastered templates or my understanding of them.

    I did my static front page, as suggested and it’s been working fine, I actually created a “main index template” and then I created a “welcome” page using html. The categories/posts on my Welcome page don’t change ever. The category pages contain all current posts and comments. What I want is to create one category as the last post on the welcome page that updates with each new post. I’ve attempted to do as you suggested, but I’m not a hundred percent sure which template to put the code you supplied in. Nor do I know what file to save where or how to edit my “Home page” other than through html.

    I’m hoping I’m clarifying myself if not perhaps looking at my blog will help. https://www.wapatu.com
    I will supply you any info you need to look around and would appreciate any assistance you can give. Thank you.

    I thought I recognised the avatar. ??

    Just to make sure I understand the situation correctly…

    Is your home page a static or posts page?
    If it’s a static page, does it use a custom template? If so, can you drop a copy of that template file into the WordPress pastebin ?

    Thread Starter wapatu

    (@wapatu)

    I think I did it, although I don’t know where it went ?? It’s under Diane / Wapatu, I think. Oh, and yes it’s a static page with “permanent” posts? I don’t know for sure, if you could look I’d appreciate it. Thanks.

    I think I did it, although I don’t know where it went

    The pastebin should have provided you with a custom url that you could have pasted here. If you can’t find it again, just drop in another copy of the file, make a note of the url and then post it here.

    Thread Starter wapatu

    (@wapatu)

    ah, ha!!! Got it this time. Learn something new everyday! I need more friends like you. Thank you. Here it is! https://wordpress.pastebin.ca/1553450

    The template file in the pastebin has your latest post appearing immediately after your Welcome message. Then, immediately after the Google ads, the rest of your posts should displayed. There’s no restriction to any category, so posts are simply displayed from all categories in date order.

    Now – which bit of that do you want to change?

    Thread Starter wapatu

    (@wapatu)

    I guess it’s more difficult to explain than I thought. Ya know when you get something in your head and you think everyone else should know what you’re talking about! ??
    I’ll try this….Each post on my home page “Welcome” page is static and is in it’s own category. None of them change. I want to ad a category into which I can post and have the posts updated with each entry, unlike my other category/posts. I want one category/post to react like most blog posts, latest first. Not static.

    Example: “You’re not the only one here”…at the bottom of the page is actually a category with a static post. What if I want the post in just that category to be updated upon entry?

    Tell me if I’m not clear again! And….thank you for your patience!!!

    Away for the 3 day weekend…..might not be online…..no need to rush a response…..Have a wonderful weekend. You’re great!

    Each post on my home page “Welcome” page is static and is in it’s own category. None of them change. I want to ad a category into which I can post and have the posts updated with each entry, unlike my other category/posts.

    Aha! Now I understand.

    I’ve placed an amended version of the file in https://wordpress.pastebin.ca/1554132

    There are 2 critical references to “Foobar” in this version:

    <?php if( in_category('Foobar') ) continue;

    and, further down:

    $dynamicposts = get_posts('numberposts=1&category_name=Foobar');

    In both cases, you’ll need to change “Foobar” to the name of your new, non-static, category.

    I think I’ve managed to emulate your current post display but, as I can’t test the template out, I can’t say for sure. It could have errors in it that stop the file dead in its tracks. So please, make a backup copy of your current Home page template file before copying this one in.

    Thread Starter wapatu

    (@wapatu)

    Well, I’m back and thank you for your quick reply again. I’ve actually tried what you suggested and I can’t seem to get it to work. Just to clarify what I did. I took the amended version and replaced my main index page template with it. And, I entered the category name in place of “Foobar.” (how’d you come up with foobar, btw?) Anyway, when I entered a post it showed up in my sidebar under recent posts,(perfect) but not on my “Welcome” page under the posts(not so good)…..soooo, I edited the html on my “welcome” page, entered the post and then another, but the first entry was still static.
    In the meantime, I feel like I’m taking lots of your time and I really don’t want to frustrate you since you’ve been so patient and such a help.
    I’m not sure if I should chalk it up to an “oh, well” and deal with what I have or not!!! Thank you, again!!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Static front page One post NOT’ is closed to new replies.