Erro = Widget + Recent Post? (3 posts)

  1. Anonymous
    Posted 8 years ago #

    Hi, guys! ;D

    I create a theme for my blog with widgets! (i lv widget! *-*)
    But... When i put the code for to get the recent post... The title's always same. (The date and the comment change @_@)

    But, i put the same code on the sidebar.php... Appears correct!

    hmmm, why don't it function in the widget? x-x

    the code:

    <?php $lastposts = get_posts('numberposts=3&offset=1');
    foreach($lastposts as $post) : setup_postdata($post);?>
    <div class="recent"><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a><br />
    <?php the_time('d',true); ?> de <?php the_time('F',true); ?> | <?php comments_number('no comment','1 comment','% comments'); ?></div>
    <?php endforeach; ?>
  2. Anonymous
    Posted 8 years ago #

    hmm... ...

    someone? XD

  3. ikiru
    Posted 8 years ago #

    I'm not sure what you're asking, but as far as I know you can't execute PHP in widgets by default. From what I understand, that's the problem you're having.

    I know there are Plugins that will let you execute PHP in widgets. Samsarin PHP Widget is the first one I found, but then I'm sure there are many more that do a similar thing.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.