• I am a designer. I am working on a church website.

    https://gracelutheransantamaria.org/

    All I want to do is display the most recent couple of posts on my home page. I think it is VERY annoying that this is so difficult and that after dozens of WordPress installations I haven’t found a simple way to do this easily.

    If you use a plugin, it uses weird formatting, or shows an ordered list. I DO NOT want that. I want the posts on the home page to look exactly like it is formatted on the blog (News) page.

    For as powerful as WordPress is, it is beyond me as why there isn’t a shortcode to do this. I’ve tried creating custom templates and everything, but it isn’t working out like I want. It would be extremely inconvenient to do something like create category pages.

    Any help would be greatly appreciated.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You’ll need to run the loop on your homepage (https://codex.www.ads-software.com/The_Loop).

    Chances are it will look similar to the loop on your news page.

    You could also try a custom query. https://codex.www.ads-software.com/Template_Tags/get_posts

    Thread Starter mgmuranaka

    (@mgmuranaka)

    I’ll look into that, but will it work necessarily? I was trying to do that but it would repeat the page info that was already there. In one case it did it in an infinite loop which was fun. Thanks for the response.

    If you do the custom query option, you’ll be able to limit the number of posts to display.

    Thread Starter mgmuranaka

    (@mgmuranaka)

    You have no idea how much you rock, it totally worked. I’ve been pulling my hair out over that for months! You would think it would be easier to find this info online, or maybe I was searching for the wrong topic?

    I just used the Access All Post Data code and it worked like a beast. I only have one question.

    For the title it’s using <?php the_title(); ?> to pull the post title, but it’s displaying the page title instead, would you happen to know how I can fix that?

    Unless you know what you’re looking for or someone answers your question in the forum, it can be a bit difficult to find info sometimes…
    As for your question, try get_the_title instead of just the_title

    You may need <?php echo get_the_title ?> on second thought

    Thread Starter mgmuranaka

    (@mgmuranaka)

    Thanks again for all your help. get_the_title and echo get_the_title are not working for some reason. I’m thinking I would have to reference the post ID somehow, but I’m not figuring anything out.

    If you paste the code you’re using I may be able to help you out.

    Thread Starter mgmuranaka

    (@mgmuranaka)

    <?php
    $args = array( 'numberposts' => 2 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php endforeach; ?>

    I was messing with the_title and all the variations weren’t working for some reason? I’m not sure if there’s any way to reference the specific post title, but the content is showing up fine so it’s weird. Thanks again-

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Adding Most Recent Post to Home Page’ is closed to new replies.