• LeoMoon

    (@leomoon)


    Hi, I’ve been trying to do this for a while now and I searched everywhere but I couldn’t make it work.

    I want to show the last post with permalink to previous entry inside a Page.

    I tried and I got it to showing the last entry only but I had to use PHP Shortcode plugin to execute php inside a page so here is the code sofar:
    [php]
    get_header();
    query_posts(‘posts_per_page=1’);
    [/php]

    Any help would be greatly appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • pierreb

    (@pierreb)

    Perhaps this is what you looking for?
    http://scribu.net/wordpress/smarter-navigation
    Adds page navigation to let users navigate between posts.

    Thread Starter LeoMoon

    (@leomoon)

    Tnx for your reply. 🙂

    That might work on an index. On a page it won’t show anything.

    I want to show the last post with permalink to previous entry inside a page.

    Nobody else knows?

    Tnx.

    esmi

    (@esmi)

    You could create a custom page template and incorporate get_posts().

    Thread Starter LeoMoon

    (@leomoon)

    I wrote what I exactly wanted:
    <?php
    get_header();
    query_posts(‘posts_per_page=1’);
    ?>
    <?php
    global $post;
    $myposts = get_posts(‘numberposts=1&offset=1&category=-3’);
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    “><?php the_title(); ?>
    <?php endforeach; ?>

    But the problem is even I wrote to show the last post first, it shows the previous link first! You would think WordPress will executes lines top to bottom.

    esmi

    (@esmi)

    If your code snippet isn’t inside backticks, it’s not readable…

    Thread Starter LeoMoon

    (@leomoon)

    I gave up. I pasted the code below into the top navigation menu. So it will show the premalink to the last blog post entry!
    <?php
    global $post;
    $myposts = get_posts(‘numberposts=1&category=-3’);
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>

    irengba

    (@irengba)

    Not sure if this will help.
    Check out this link http://codex.wordpress.org/Template_Tags/get_posts

    The code has to be inside the wordpress loop.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Show Last Post With Permalink To Previous Entry’ is closed to new replies.