All you need is a simple query and to iterate over that query a couple of times so you can build the two required lists. WP_Query
has a convenient method for resetting the pointer in the posts array, so you can loop over it again, called rewind_posts
though i believe inside custom loops you have to reference the method directly..
Anyway, here’s the kind of thing you’re looking for, simply make adjustments as necessary..
<?php
$featured = new WP_Query;
$featured->query( array(
'meta_query' => array(
array(
'key' => 'myslider_show_post_slider',
'value' => array('on','1'),
'compare' => 'IN',
'type' => 'CHAR',
)
),
'post_type' => 'post',
'post_status' => 'publish',
'ignore_sticky_posts' => '1',
'posts_per_page' => '7' //The number of post in the slider.
) );
if( $featured->have_posts() ) :
?>
<div class="slider">
<ul class="main-wapper">
<?php
while( $featured->have_posts() ) : $featured->the_post();
?>
<li>
<?php the_post_thumbnail(); ?>
<div class="main-item-desc">
<h2><a title="<?php the_title_attribute(); ?>" href="https://wordpress.stackexchange.com/questions/14396/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p>Where's this description suppose to be coming from?</p>
</div>
</li>
<?php
endwhile;
$featured->rewind_posts();
?>
</ul>
</div>
<div class="navigator-outer">
<ul class="navigator">
<?php
while( $featured->have_posts() ) : $featured->the_post();
?>
<li>
<div>
<?php the_post_thumbnail('Slider'); ?>
<h3><?php the_title(); ?></h3>
<p><span class="date"><?php the_time( 'd.m.Y' ); ?></span> | <span class="category"><?php the_category(','); ?></span></p>
</div>
</li>
<?php
endwhile;
?>
</ul>
</div>
<?php
endif;
?>
Firstly, there was a stray closing DIV in the HTML you posted, so i simply removed that from the code above.
Secondly, the checkbox does not have a value specified, in such cases a checkbox isn’t given a specific value, the browser assigns the checkbox one, i’m not sure whether there’s a common value that all browsers will use, but Firefox produces the value on
, but i accounted for the possibility that the browser may assign a value of 1
, ideally the checkbox should be given a implicit value to ensure consistent behaviour, eg..
echo '<input type="checkbox" value="1" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
Any questions, lemme know..