How do you create a generic template page for eleven40?

Community Forums Forums Design Tips and Tricks How do you create a generic template page for eleven40?

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  ramseyp 1 year, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33466

    Chris Moore
    Participant
    Post count: 136

    Hello,

    I am trying to create a customized template page to use as a drop-down option in the Page Attributes section (after adding a page).

    I got the page working with this much so far, but much is missing:

    /*
    Template Name: Thank You Page - Email
    */
    get_header();
    get_sidebar();
    get_sidebar( $name = alt );
    get_footer();

    I would like to fill in the gaps in the code so that I have a fully formed and structured page, just like a 3-column page in the eleven40 child theme (exactly like this page: http://demo.studiopress.com/eleven40/sample/sub-page-11/)

    I would also like to have one last thing: I would like to have a loop that displays the last 5 posts of the blog in the middle of the content area of the page.

    Thanks!


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #33469

    ramseyp
    Participant
    Post count: 99

    Hi there,

    First thing you need to do is redo the code you have in the template. Since you’re using a Genesis child theme, the page template needs to become part of the Genesis environment. Redo you template to read like this:


    <?php
    /**
    * Template Name: Thank You Page - Email
    *
    */

    genesis();

    That right there will make it a working page template and make it part of the genesis environment.

    The second part you mention would involve replacing the standard post content functionality with a custom loop. With Genesis, you add or remove actions (functions) to manipulate the output. If you’re not familiar with Nick’s Genesis Framework overview, start here.

    You would want this in your page template, before the genesis(); bit:

    remove_action( 'genesis_loop','genesis_do_loop' );

    This unhooks the default loop of that page so you can replace it with a custom one that grabs the 5 posts:

    add_action( 'genesis_loop','my_custom_loop' );

    Now we replace genesis_do_loop with our own function, my_custom_loop where the custom loop will go. We have to create this function before it can do anything.

    function my_custom_loop() {

    }

    Between these brackets, { and }, we write what the function should do. You want the 5 latest Posts, so something like this would work:

    function my_custom_content() {
    $args = array(
    'posts_per_page' => 5,
    'post_status' => 'publish',
    );
    genesis_custom_loop( $args );
    }

    The finished page template would look something like:


    5,
    'post_status' => 'publish',
    );
    genesis_custom_loop( $args );
    }

    remove_action( 'genesis_loop','genesis_do_loop' );
    add_action( 'genesis_loop','my_custom_loop' );

    genesis();



    #33482

    Chris Moore
    Participant
    Post count: 136

    I’m sorry, things didn’t come out too clearly, I think because of the way code is handled in the forums here… Are you saying this:

    remove_action( 'genesis_loop','genesis_do_loop' );
    add_action( 'genesis_loop','my_custom_loop' );

    function my_custom_loop() {
    function my_custom_content() {
    $args = array(
    'posts_per_page' => 5,
    'post_status' => 'publish',
    );
    genesis_custom_loop( $args );
    }
    }
    genesis();


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #33498

    ramseyp
    Participant
    Post count: 99

    Apologies, the page template should contain ( besides the opening php tag and the comment block with the template name in it):


    remove_action( 'genesis_loop','genesis_do_loop' );
    add_action( 'genesis_loop','my_custom_loop' );
    function my_custom_loop() {
    $args = array(
    'posts_per_page' => 5,
    'post_status' => 'publish',
    );
    genesis_custom_loop( $args );
    }
    genesis();


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.