Query not working in sidebar widget
-
I created a Query to list thumbnails of posts from a category for a sidebar widget. I took a script I used to query posts on a home page which actually works very well but the one in the sidebar doesn’t work and I can’t figure out why.
Thanks for any tips how to fix it.
Code:
<?php /* Plugin Name: Pohřešované osoby Version: 1.0 Author: .... */ class ptPohrOsoby extends WP_Widget { function ptPohrOsoby() { $widget_ops = array('classname' => 'ptPohrOsoby', 'description' => 'Obrázkový seznam pohřešovaných osob' ); $this->WP_Widget('ptPohrOsoby', 'Pohřešované osoby', $widget_ops); } function form() { ?> Not editable atm. <?php } function widget() { echo $before_widget; ?> <div class="title"> <p> Pátrání po osobách </p> <hr/> </div> <div class="patrani"> <?php query_posts('cat=17&posts_per_page=4'); ?> <?phpif ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="osoba"> <div class="kraj <?php post_class(); ?>"> <?php global $post; foreach(get_the_tags($post->ID) as $tag) { echo $tag->name; } ?> </div> <?php the_post_thumbnail( 'patrana_osoba' ); ?> </div> <?php endwhile; endif; ?> <?php wp_reset_query(); ?> <div class="clearer"></div> <hr/> </div> <?php echo $after_widget; } } add_action( 'widgets_init', create_function('', 'return register_widget("ptPohrOsoby");') ); ?>
- The topic ‘Query not working in sidebar widget’ is closed to new replies.