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.
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 ! 🙂
Hello CMB2 gang.
It's been a while since I've included CMB2 on a project and, as I'm getting a new theme (not for distribution) set up, I'm wondering what the current best practice is?
I'm thinking it's one of the following:
I'm also curious if the best method is different depending on my purpose. Say, if I were building a plugin for redistribution, would I include CMB2 as a dependency in the project or just note that users need to install the official CMB2 plugin and leave it out?