WordPress.org

Ready to get started?Download WordPress

Forums

How to Display Recent Last 48 Hours Posts in WordPress (7 posts)

  1. clip2ni
    Member
    Posted 3 years ago #

    hi

    How to Display Recent Last 48 Hours Posts in WordPress ?

    its very important to me !

  2. clip2ni
    Member
    Posted 3 years ago #

    laso

    now i am using this code :

    <?php
    global $post;
    $myposts = get_posts('numberposts=20');
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>

    that its for display last 20 post updated ! but its not usable to me

  3. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    there are time parameters for the query:
    http://codex.wordpress.org/Function_Reference/WP_Query#Time_Parameters

    caveat:
    not tested, if all these methods work with get_posts()

  4. clip2ni
    Member
    Posted 3 years ago #

    !!

    i write this code but its dont work(even it dont display):

    <?php
      function filter_where($where = '') {
    	$where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
        return $where;
      }
    add_filter('posts_where', 'filter_where');
    $query = new WP_Query( $query_string );
    ?>

    plz help to me

  5. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    where are you going to use the code?

    in a page template?
    or in index.php?

    the following might work in a page template:
    http://pastebin.com/k7fx4iZf

    can you post a link to your site to illustrate what you are trying to achieve?

  6. clip2ni
    Member
    Posted 3 years ago #

    lsidebar.php

  7. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try to use this code:

    http://pastebin.com/1chJetff

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags