Description
get_collection_by_id
will return the database record for a Collection with a given ID.
Usage
<?php get_collection_by_id($id); ?>
Parameters
- $id (integer) - The ID of the collection you wish to retrieve. This should be a number, ideally matching the ID of an collection already existing in your archive.
Example
Using get_collection_by_id
, you can display metadata for a specific collection anywhere in your theme. The following code will set the current collection to be the collection with an ID of 7, and will then echo the name of that collection, wrapped in an h2
tag.
<?php set_current_collection(get_collection_by_id(7)); echo '<h2>'.collection('Name').'</h2>';