Thomas –
Okay so i’m having a little problem figuring this out.
I can’t get my widget to work like it was used to.
I understand that this isn’t your problem in any way but I would really appreciate it if you would care to take a look at it.
So if you do please read on else…. well. Thank you for your time.
I have taken the basic widget that shows all posts from the blog instance. What I did is added the jobman_job post_type and let it sort on date.
What used to happen was that the news and the jobs were mixed together.
Here is how I did it. I hope you can see the problem:
function widget( $args, $instance ) {
extract( $args );
function list_all_posttypes() {
global $post;
global $wp_query;
echo '<ul>';
rewind_posts();
// Create a new WP_Query() object
$wpcust = new WP_Query(
array(
'post_type' => array(
'jobman_job',
'post'
),
'cat'=>'-35,-42,-39,-43,-41,-40,-52',
'showposts' => '4',
)
);
if ( $wpcust->have_posts() ):
while( $wpcust->have_posts() ) : $wpcust->the_post();
$displayenddate = get_post_meta( get_the_ID(), 'displayenddate', true );
$displaystartdate = get_post_meta( get_the_ID(), 'displaystartdate', true );
if( '' != $displayenddate && strtotime( $displayenddate ) <= time() ) {
$my_post['ID'] = get_the_ID();
$my_post['post_status'] = 'draft';
wp_update_post($my_post);
continue;
}
?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php
endwhile; // close the Loop
endif;
wp_reset_query(); // reset the Loop
echo '</ul>';
M.