Support » Plugin: Church Community Builder Core API » Event List in a Group Custom Post Type

  • Resolved jeremysmcknight

    (@jeremysmcknight)


    Please excuse the design while I’m trying to figure this out but I’m trying to add a list of upcoming events under a certain group. When creating an event in CCB inside of my group I set to public and it syncs over fine to my wordpress database and it takes on the Group Name as McKnight Trail Guide Group (mcknight-trail-guide-group). I even see it in a list format I’m assuming it is a default archive.php here https://trailhead.church/ccb_core_calendar_group_name/mcknight-trail-guide-group/
    So I know it is there 🙂

    On to my group single page which is here https://trailhead.church/groups/mcknight-trail-guide-group/
    For the life of me I can’t insert this list into my custom template. In noway I’m a developer I just tend to dabble but I’m sure I’m missing something so small. Here is the code I’ve been using.

    <?php
      $custom_taxterms = wp_get_object_terms( $post->ID, 'mcknight-trail-guide-group', array('fields' => 'ids') );
        $args = array(
        'post_type' => 'ccb_core_calendar',
        'post_status' => 'publish',
        'posts_per_page' => 1,
        'orderby' => 'ASC',
        'tax_query' => array(
            array(
                'taxonomy' => 'mcknight-trail-guide-group',
                'field' => 'id',
                'terms' => $custom_taxterms
            )
        ),
        'post__not_in' => array ($post->ID),
        );
        $related_items = new WP_Query( $args );
        // loop over query
        if ($related_items->have_posts()) :
        echo '<ul>';
        while ( $related_items->have_posts() ) : $related_items->the_post();
        ?>
            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php
        endwhile;
        echo '</ul>';
        endif;
        // Reset Post Data
        wp_reset_postdata();
        ?>

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • I figured it out, it was a tag and not taxonomy. So easy… here is the code incase someone else needs it.

    <?php
    echo '<ul>';
    
    //The Arguments
    $args = array(
        'post_type' => 'ccb_core_calendar',
        'ccb_core_calendar_group_name' => 'mcknight-trail-guide-group' //should use the slug name not the full name
    );
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
      <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile;
    
    echo '</ul>';
        ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Event List in a Group Custom Post Type’ is closed to new replies.