Show latest post on static page for Travelify WordPress theme?

Hi there,

Basically, I’ve looked at several different ways of doing this, but I’m not hugely proficient in CSS & PHP so I came here seeking help.

I basically want my front page on my WP site to show a little welcome message, and then my latest post below that.

I’m not sure if it’s easier to have a static page and then add the code to show the latest post beneath that, or the other way, show latest posts (set to 1) and have my welcome message above that. I thought maybe the former was easier.

The way I want to do it, is to have the post “block” seperate to the actual welcome message “block.” I’ve tried messing with the CSS using Chrome’s source editor and came up with this (which is exactly how I want to do it), I’m just not sure how to go about doing it. Any help would be massively appreciated!

Many thanks,
Tyler :slight_smile:

I think we want to do the same thing. I think the ‘recent posts’ widget in the ‘homepage widget 1’ area should do it, but I don’t know how to make the ‘homepage widget 1’ area show up underneath the body text on my home page.

I hope the answer will be able to help us both!

You can achieve this by adding this PHP code to your Child Theme functions.php file. Sample Travelify Child Theme can be downloaded from here.

// Add custom text above blog on front page
add_action( 'travelify_before_loop_content', 'custom_introduction' , 13 );

function custom_introduction() {
	if ( is_home() || is_front_page() ) {
		echo '<section class="post type-post home-intro"><article>
			<div class="entry-content clearfix">
			<p>This is my content</p>
			</div>
			</article>
			</section>';
	}
}

Now you have to edit text that appears as:

<p>This is my content</p>

You can use any HTML there.

That worked, thank you very much!

However, this welcome message appears on my “news” page where I’d like to display all of my posts. Is it at all possible to make the message exclusive to the front page? And also remove the previous/next buttons from just the front page?

This is why perhaps I thought adding the latest post code to the front page would’ve made it easier.

Try removing this part of code:

is_home() ||

That doesn’t work, unfortunately. It does if I set my reading settings to front page as a welcome page and then the posts page as my news page, but the front page just displays the message and no latest post. I understand that it is very specific what I am asking for help with, but I hugely appreciate it, thank you.

Still don’t get your setup but you can target it even more specifically using is_page function. Here you can read more information about it.

Okay, the site I am working on is www.1338sqn.org.
The news page (www.1338sqn.org/news) is setup perfectly at the moment, but I want to display the latest post “block” on the news page, on my homepage beneath the welcome message, where just the page title is displayed.

I have my reading settings setup so that my frontpage is the “Welcome!” page and the posts page is news (1338sqn.org/news).

Is it at all possible to mimic the latest post “block” on the news page, on my front page beneath the welcome message?

This theme has 3 different blog templates and you can use it for as many pages as you want. See theme documentation and pay close attention to “10.How to set up Blog Page”. Don’t use WordPress built in option that now causes all your problems.

I’m trying to replicate the same set up that tylerin2d is doing…my question is, can I have more than just the first blog post (most recent) show up below my static page content? I’d like to have my last 5 or X amount of blog posts show up. Thanks so much for your awesome feedback and your time!

Astrid

@astrid

That’s exactly what @tylerin2d achieved with suggestions that I provided above. He created a static HTML page with a regular blog at the bottom.

This solution does require to use your own HTML but that’s the best solution that there is. Just give this code a try to see how it works. Just make sure that you are using blog page at the front page before your proceed.