Forum
How do I tell the blog function to get the latest post?
How do I tell the blog function to get the latest post? I'm hoping for something like this:
<?php
?s="latestpost";
perch_blog_post(perch_get('s'));
?>
I should preface by saying I don't really know php or the terminology.
I know I could use perch_blog_custom();
but the real reason I want to do this, is so the search results will replace the blog post when the search button is pressed. In other words, there is a search form on the same page as the blog. When someone searches, the blogpost disappears and the search results show up in its place. This only seems to work when the blog post is originally loaded with perch_blog_post(perch_get('s'));
The rub is that no blog post comes up with this custom function unless the url contains ?s="blog-title-here"
. Hope that makes sense. Thanks in advance!
Like this:
Thanks Drew. That function will give me a list with a link to the most recent post. I'm looking for a way to pass the most recent post to this function when the page loads:
perch_blog_post(perch_get('s'));
This is what I'm using now:
The problem is that when the search feature is used, it just adds the search results above the blog post instead of replacing it. This works on the regular post pages, but not this one. Here is the url:
https://beta234.darbyfox.com/blog/askdarbyfox-blog.php
Many Thanks!!
Ok. What do you have the in page? You are in control of what is displayed.
Ok, so if you don't want the post to display when there's a search, just test for the search parameter.
Thank you sir. Works perfectly!