Displaying multiple 'collections' on home page?

Hi! I’m trying to figure out how to display multiple ‘collections’ on the homepage, instead of just ‘featured collection’. Because the code is for ‘featured collection,’ it shows one randomly selected collection, but I would like to display all of them. Thank you!!

The working site for reference: http://mundanemilitarisms.com/

You have to do a little custom theme editing to get multiple featured collections on the homepage.

The function get_records can get as many featured collections as you want (or set $numCollections to zero to get all of them):

$numCollections = 5;
$collections = get_records('Collection',  array('featured' => 1, 'sort_field' => 'random'), $numCollections);

then for each one you want to display it:

foreach ($collections as $collection) {
    echo $this->partial('collections/single.php', array('collection' => $collection));

Hi!! Thank you so much for this response. Specifically in the index.php code, how does this fit in? Currently the code looks like this:

<?php echo head(array('bodyid'=>'home', 'bodyclass' =>'two-col')); ?>
<div id="primary">
    <?php if ($homepageText = get_theme_option('Homepage Text')): ?>
    <p><?php echo $homepageText; ?></p>
    <?php endif; ?>

    $category = get_theme_option('Display Featured Collection');
    if ($category === null || $category === ''):
        $category = 3;
        $category = (int) $category;
    if ($category):
    <!-- Featured Collection -->
    <div id="featured-collection" class="featured">
        <h2><?php echo __('Categories'); ?></h2>
        <?php echo random_featured_collection($category); ?>
    </div><!-- end featured collection -->
    <?php endif; ?>

</div><!-- end primary -->

<div id="secondary">
    $recentItems = get_theme_option('Homepage Recent Items');
    if ($recentItems === null || $recentItems === ''):
        $recentItems = 3;
        $recentItems = (int) $recentItems;
    if ($recentItems):
    <div id="recent-items">
        <h2><?php echo __('Recently Added Items'); ?></h2>
        <?php echo recent_items($recentItems); ?>
        <p class="view-items-link"><a href="<?php echo html_escape(url('items')); ?>"><?php echo __('View All Items'); ?></a></p>
    </div><!--end recent-items -->
    <?php endif; ?>
    <?php fire_plugin_hook('public_home', array('view' => $this)); ?>

</div><!-- end secondary -->
<?php echo foot(); ?>

Thank you so so much!!

You’d put the code in place of where you currently have echo random_featured_collection($category);

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.