WordPress.org

Ready to get started?Download WordPress

Forums

Oxygen
Tutorial: how to populate the Oxygen slider with sticky posts (6 posts)

  1. Mark
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/themes/oxygen/

  2. rbadan
    Member
    Posted 1 year ago #

    Hey Mark I've been looking for a solution to this problem in days! and I finally stumbled upon your post. Im working with the Oxygen theme and trying to display a certain category in the slider, is that possible?
    Thanks!

  3. Mark
    Member
    Posted 1 year ago #

    Sure. Change the line above to:

    $args = array( 'posts_per_page' => 6, 'cat' => 2 );

    And change "2" to your category ID. Basically this is just a standard post query so you can change whatever you like. The posts_per_page => 6 thingy will make sure you don't overfeed the slider - it doesn't look as good with more than six posts.

  4. erlingur
    Member
    Posted 1 year ago #

    I'm looking for a way to switch out the "Recent articles" and "More articles" on the front page for categories based on categories. Is it as simple as switching out the "$args = array" line for a category ID line like the one above?

    UPDATE:
    It is.

    This line in the "page-template-front.php" (copied to a child theme):
    <?php $args = array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => 3, 'meta_key' => '_oxygen_post_location', 'meta_value' => 'primary' ); ?>

    is changed to this:

    <?php $args = array( 'posts_per_page' => 6, 'cat' => 20 ); ?>

    where "20" is the ID for my Film Reviews.

    The same goes for the line for the "More articles" line

    And this happens:

    My site

    ...now I just need to find out how to make the images in the slider appear as they should...

  5. savagex925
    Member
    Posted 1 year ago #

    Thanks for the info Erlingur

    Could you explain how you changed the name of recent articles and more articles to latest reviews and features?

    Also how did you add images to the more articles section on the homepage?

  6. lacanadienne58
    Member
    Posted 1 year ago #

    To change the name : search (Ctrl F) on the directory of your website files. Then, change the lable where you'll find it.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic