Forums

How do i use recent post widget on post (5 posts)

  1. baokychen
    Member
    Posted 3 years ago #

    How do i use recent post widget on post

    I want to use the default widget - Recent Post and set show 15 entries on my post

    I have a post which call Updates , display the latest post base on the algorithm Widget - Recent post

    Normal recent post plugins cant show in the order that Widget - Recent post show cause i use some wp-sticky plugin and other plugins.

    Only the default built in recent post widget can show in the order i want , I wanna put the data in my post , phpExec installed and can execute php.

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    That query is at line 1310 in wp-includes/widgets.php so look in that area of code for idea.

  3. baokychen
    Member
    Posted 3 years ago #

    Dear moderator, I have look onto it, but how do i call it to my post.

    I have php enabled on the post, and thanks again for your response.

  4. MichaelH
    Volunteer
    Posted 3 years ago #

    Might be easier to just look at a recent post plugin such as http://wordpress.org/extend/plugins/recent-posts-plugin/

    But this should work for you:

    <?php
    // retrieve 5 recent posts, not including the current post
       $args=array(
       'post__not_in' => array($post->ID),
       'showposts'=>5,
       'caller_get_posts'=>1
       );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    echo 'Recent Posts';
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php
    endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  5. baokychen
    Member
    Posted 3 years ago #

    dear moderator, the code you provide i apply it in my post.

    However, my post was call "Updates" but when put in your phpcode, it change to another post and its content.

    I think there something wrong with the code as it use other post content as my "updates post".

    Somehow got overwrite.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic