• 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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • That query is at line 1310 in wp-includes/widgets.php so look in that area of code for idea.

    Thread Starter baokychen

    (@baokychen)

    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.

    Might be easier to just look at a recent post plugin such as https://www.ads-software.com/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().
    ?>

    Thread Starter baokychen

    (@baokychen)

    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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do i use recent post widget on post’ is closed to new replies.