Tutorial: how to populate the Oxygen slider with sticky posts
-
Oxygen is a beautifully designed theme. However, I find the way the frontpage template is set up a bit counterintuitive: the user has to hand-pick the posts that appear in the Featured (slider), Primary and Secondary loops, and moreover has to do this through the Oxygen-provided post location metabox instead of using more familiar methods like the “Sticky” feature.
Here is how to populate the Featured content slider with Sticky posts instead of with posts from the “Featured” location in the Oxygen metabox:
1. Create a child theme. Never fiddle with original theme files, it breaks forward compatibility and cuts you off from updates.
2. Copy the featured-content.php template file from the Oxygen theme folder into your Oxygen child theme.
3. Find the following line:
$args = array( 'posts_per_page' => 6, 'meta_key' => '_oxygen_post_location', 'meta_value' => 'featured', 'post__not_in' => get_option( 'sticky_posts' ) );
(If you decode this you’ll see that this line makes the slider template look for all posts that (1) have their
_oxygen_post_location
set to “featured”, and (2) are not sticky.)4. Change that line into the following:
$args = array( 'posts_per_page' => 6, 'post__in' => get_option( 'sticky_posts' ) );
What this does is tell the slider to get its posts from the inventory of posts that are set to sticky.
In a next topic I may elaborate on how to populate the “Recent articles” and “More articles” areas on the front page automatically from categories, rather than having to laboriously pick them yourself.
- The topic ‘Tutorial: how to populate the Oxygen slider with sticky posts’ is closed to new replies.