Skip to content

Writing a custom page template

victorjonsson edited this page Oct 24, 2014 · 24 revisions

There are several php functions that you can use in your theme to write a custom page template.

Related documents:

Template functions

arlima_get_list() : Arlima_List

Returns the article list related to currently visited page. Will return false if we're not visiting a page or if the the page doesn't have a related article list.

arlima_has_list() : Boolean

Tells whether or not we're visiting a page that has a related article list.

arlima_is_preview() : Boolean

Tells whether or not we're visiting a page that has a related article list and that the version of the list is a preview version.

arlima_edit_link() : void

Function that displays a link to wp-admin where currently visited article list can be edited

arlima_render_list( $list, $args=array() ) : String

This function is not needed unless your're programmatically rendering the list

arlima_load_list( $id_or_slug, $version=false, $include_future_post=false ) : Arlima_List

This function is available as of version 2.8. Use this function to load an article list. The parameter $version can be either the ID number of a certain version or the string 'preview' if you want to load the latest preview version of the list. Set variable $include_future_post to true if you want the list to include articles that is connected to future posts.

Example code

Here's a piece of example code for a custom page template that you can use in your theme. Name the file page-arlima.php

<?php
/**
 * Template Name: Article List Page
 * -------------------------------------
 */
get_header();
?>
<div id="primary" class="arlima-content">
    <div id="content" role="main">

        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        
            <?php if( !arlima_has_list() ): ?>
                <header class="entry-header">
                    <h1 class="entry-title"><?php the_title(); ?></h1>
                </header>
            <?php endif; ?>
        
            <?php if( arlima_is_preview() ): ?>
                <p class="arlima-preview-notice arlima-edit-list">
                    This is a preview of article list 
                    &quot;<?php echo get_arlima_list()->getTitle() ?>&quot;
                    <a href="<?php the_permalink() ?>">Click here to reload latest published version</a>
                </p>
            <?php elseif( arlima_has_list() ): ?>
                <?php arlima_edit_link(); ?>
            <?php endif; ?>
                
            <div class="arlima-content">
                <?php the_content(); ?>
            </div>
        
            <footer class="entry-meta">
                <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
            </footer>
        
        </article><!-- #post-<?php the_ID(); ?> -->
    </div>
</div>
<?php 
get_sidebar();
get_footer();

This Wordpress plugin was created by Swedish newspaper Västerbottens-Kuriren to give its editorial staff an easy to use tool for customizing the front pages of their online magazines.

Installing Arlima

  1. Download the latest release from github and unzip the folder in your plugin directory.
  2. Open up wp-admin and activate the plugin.
  3. Go to "Article lists" -> "Edit lists" in wp-admin and create your first article list.
  4. Open up a page (or create it) in wp-admin. Down to the right you will see a meta box labeled "Arlima" where you choose the list that you created on step 2.
  5. Go to "Article lists" -> "Manage lists" and start stuffing your article list with interesting content.

Top links

Clone this wiki locally