I tried the Following (whihc lists custom post types called Static Content):
<?php
add_action("widgets_init", array('Widget_name', 'register'));
class Widget_name {
function control(){
$custom_posts = new WP_Query();
$custom_posts->query('post_type=page_content&page_sections=Lastest');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>
<div class="block-7 border-top">
<h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a>
<p><?php the_excerpt(); ?></p>
</div>
<?php endwhile;
}
function widget($args){
echo $args['before_widget'];
echo $args['before_title'] . 'Your widget title' . $args['after_title'];
echo $args['after_widget'];
}
function register(){
register_sidebar_widget('Widget name', array('Widget_name', 'widget'));
register_widget_control('Widget name', array('Widget_name', 'control'));
}
}
?>
But no luck. There’s nothing displayed in the widget.
Any suggestions?
Figured out how (Thanks to WordPress Codex):