Custom Metaboxes and Fields (CMB) will create metaboxes and forms with custom fields that will blow your mind. This is version 2.0 and has been completely rewritten.
show_on_cb
box property to determine if/when a box should show
'show_on' => array( 'key' => 'page-template', 'value' => 'page-specials.php' ),
Hey,
i’m new to cmb2 and i hope you can help me.
I want to echo my posts but only when i triggered a checkbox in backend.
this is my current code im a little bit lost.
<?php get_header(); ?>
<?php
$taxonomies = get_object_taxonomies( array( 'post_type' => 'faq',) );
foreach( $taxonomies as $taxonomy ) :
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( array( 'taxonomy' => 'faqt', 'parent' => 0, 'hide_empty' => 0, ) );
foreach( $terms as $term ) : ?>
<div>
<h3><a href='faqt/<? echo $term->slug; ?>'><? echo $term->name; ?></a></h3>
</div>
<?php
$args = array(
'post_type' => 'faq',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term->slug,
)
)
);
$posts = new WP_Query($args);
if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>
<ul>
<li><a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?></a></li>
</ul>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>
<a href='faqt/<? echo $term->slug; ?>' class=“btn btn-secondary”>Alle Fragen</a>
</div>
<hr/>
<?php endforeach;
endforeach; ?>
<?php get_footer(); ?>
I hope you guys can help me
thx ! 🙂