Skip to main content

How to use “Collections”

The “Collections” feature is used to create a specific list of games manually. It can be used for highlighted games, staff-picked games, promoted games, or any other purpose.

Here are the step-by-step instructions on how to use it:

Visit the “Collections” page. There, you will see a small form on the right.”

Fill the collection name and the list of game IDs you want to include in this collection. To obtain the game ID, open the “Game list” in a new tab, copy the game ID, and then paste it into the “game ids” field.

In this guide, I will select 4 games with the IDs 265, 264, 262, and 227. Here is the result:

I used “sample” as my collection name, and the game IDs are separated by commas.

Then, click the “Add” button.

Next, let’s display the Collection list using PHP code. Currently, there’s no way to display a collection without using PHP code or editing the theme code.

I will display the Collection list on a custom page. Use the “Custom Pages” plugin to easily create a custom page.

I named my page “page-test”. You must prepend the name with “page-“.

Then click “Create page”.

PHP code:

<?php

$collection = get_collection('sample', 10);
$games = $collection['results'];
foreach ( $games as $game ) {
   	echo $game->title;
    echo '<br>';
}

?>

“Save” it, then visit your page, if the page name is “page-test”, the url will be yourdomain.com/test

Result:

get_collection('sample', 10) “10” is the maximum number of games you want to retrieve from the list.

If the basic code provided above works, let’s polish it to match the theme style.

PHP code:

<?php
$page_title = 'test';
$meta_description = '';
?>
<?php include  TEMPLATE_PATH . "/includes/header.php" ?>
<div class="container">
  <div class="game-container">
    <div class="row">
    <?php

    $collection = get_collection('sample', 10);
    $games = $collection['results'];
    foreach ( $games as $game ) {
        include  TEMPLATE_PATH . "/includes/grid.php";
    }

    ?>
    </div>
  </div>
</div>
<?php include  TEMPLATE_PATH . "/includes/footer.php" ?>

Result:

You can access get_collection() anywhere as long as inside theme scope, it can be called from functions.php, custom.php, home.php and more.