5 Comments


  1. I looked at this a little while back and it looked like it could make things easier but I did think the wrapper around it made it look simpler than it would be. I guess you’ve proved me right.

    The thing is, there are some amazing widgets (Justin Tadlock’s for example) that let you run just about any query you want so it is hard to think of a situation where you would need to create your own.

    The problem with your code is that you started a loop but never closed it again, so PHP was expecting an endforeach and got the end of the function instead.

    Andrew’s last blog post..WLTC Plugin Competition: Max Image Size Control


  2. I could code a new widget in 10 minutes (assuming I already have my function(s) created). There’s really no need for developers to work with a widget creator, especially with the new widget class in WP 2.8. Things like this should be for Average Joe to use.


  3. Just commenting to say, yes, you should be using Justin’s Query Posts Widget. It’s super impressive.



  4. Jeff,

    Thanks for checking out our tool. I think you get a better idea of who would benefit from our tool by reading our post on the subject.

    Here’s the corrected code that would have made your widget work.

    Since we include your code as part of a function you need to get our of php mode “?>” and at the end you need to start php end with “<?PHP”.

    Also I finished out the loop for you. You just didn’t copy enough from the wordpress site.

    ?>
    
      < ?php global $post; $myposts = get_posts('numberposts=5&offset=1&category=1'); foreach($myposts as $post) : ?>
    • ">< ?php the_title(); ?>
    • < ?php endforeach; ?>
    < ?php

    I hope you find this useful.

    Glenn

Comments are closed.