Archived

This topic is now archived and is closed to further replies.

  • 0

Best way to insert latest post into a page

Question

Posted · Report post

Hi there.

what is the best way to insert a latest post into a page without using a sidebar widget?

I want to add the lastest post to a home page which is not the blog home page.

thanks.

Share this post


Link to post
Share on other sites

9 answers to this question

Posted · Report post

Try using the function and shortcode here (under "Most Recent Post"): http://wpmu.org/10-awesome-shortcodes-for-your-wordpress-blog/

But first, please check to make sure that you're using either base theme or the PL Customize Plugin (you'll need to insert the function into the bottom of the functions.php file in either one). If not, let us know and we'll direct you.

Share this post


Link to post
Share on other sites

Posted · Report post

Hi Catrina, thanks for this.

I am using the Pagelines framework - not sure if that is the base theme?

Share this post


Link to post
Share on other sites

Posted · Report post

You'll need to install the base theme. On your Dashboard, go to PageLines > Store > Themes > Free and the Base theme should be at the top. Install it and then activate it in Appearance > Themes.

Share this post


Link to post
Share on other sites

Posted · Report post

Why must i activate it - i have already customised the framework which i activated:

Current Theme

PageLines Framework

A responsive drag-and-drop platform for professional websites based on HTML5 and CSS3. PageLines will help you do amazing things faster & easier than ever before. Designed by PageLines in California. Twitter @pagelines</p>

Share this post


Link to post
Share on other sites

Posted · Report post

The base theme doesn't affect what you've already set up. It's simply a child theme that inherits the characteristics of the parent theme, PageLines Framework. For more insight, please see here: http://www.pagelines.com/wiki/How_to_Use_the_Base_Theme

Share this post


Link to post
Share on other sites

Posted · Report post

Hi Catrina, ok, i have done all of that, works like a charm, thanks so much.

A quick question about formatting (It all comes in as text without any <h1> etc).

In the code below, i have highlighted what i assume i must add to target the headline etc, but i am not a programmer so am not sure about the ""'s etc.

Is the code below correct?

function wptuts_recentpost($atts, $content=null){

$getpost = get_posts( array('number' => 1) );

$getpost = $getpost[0];

$return = $getpost->"<h3>"post_title ."</h3>" "<br />" . $getpost->post_excerpt . "…";

$return .= "<br /><a href='" . get_permalink($getpost->ID) . "' target=_blank><em>read more →</em></a>";

return $return;

}

add_shortcode('newestpost', 'wptuts_recentpost');

Thanks so much for the help!

Share this post


Link to post
Share on other sites

Posted · Report post

Are you just trying to style the <h3> heading?

Share this post


Link to post
Share on other sites

Posted · Report post

Pretty much, yes.

That and to make the link open in a new window.

Share this post


Link to post
Share on other sites

Posted · Report post

Can you please post a link to your site?

Share this post


Link to post
Share on other sites