Basically i have a custom post with a custom metabox, with a checkbox inside it.
If you check the box i want something (styled box) to appear within the post loop.
If not checked the box doesn't appear...
I have the following in my template page..
<?php get_header(); ?>
<?php $loop = new WP_Query( array( 'post_type' => 'books','posts_per_page' => '-1') ); ?>
<?php while (have_posts()) : the_post() ; $meta = get_post_meta( get_the_ID(), 'rw_title_block', true ); ?>
<?php if( checked( $meta, 1, false ) ) : ?>
check box is checked to display stuff like... <?php the_title(); ?>
<?php endif ?>
not checked ignore this stuff...
<?php endwhile; ?>
<?php wp_reset_query() ?>
<?php get_footer(); ?>
The metabox functions code (this seems to display fine in the admin.)
$meta_boxes[] = array(
'id' => 'test_metabox',
'title' => 'Test Metabox',
'pages' => array( 'books', ),
'context' => 'normal',
'priority' => 'high',
'show_names' => false,
'fields' => array(
array(
'name' => 'Test Checkbox',
'desc' => 'field description (optional)',
'id' => $prefix . 'title_block',
'type' => 'checkbox',
),
),
);
Thank you for any help, it would be a life saver.
Regards.