CMB2 Checkbox to enable/disable post output
-
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 ! ??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘CMB2 Checkbox to enable/disable post output’ is closed to new replies.