Skip to content

Instantly share code, notes, and snippets.

@josesayago
Last active December 18, 2015 06:59
Show Gist options
  • Save josesayago/5743567 to your computer and use it in GitHub Desktop.
Save josesayago/5743567 to your computer and use it in GitHub Desktop.
Example of use of Single Latest Posts embedded into a template file. This one includes parameters not yet made publicly available.
<?php
/*
Template Name: SLPosts
*/
/* Include header */
get_header();
?>
<!-- Template sub-parent wrapper -->
<div class="inner-page">
<!-- Template content wrapper -->
<div class="page-content">
<?php
// Check if the plugin has been activated
if( function_exists( 'single_latest_posts' ) ) {
/**
* Custom parameters
* Set only those you want to use
*
* auto_excerpt allows SLPosts to create an extract from content
* by default WordPress excerpts are 55 words length, so
* auto_excerpt is the best option when setting excerpt_length value
* greater than 55 words length
*/
$parameters = array(
'title_only' => 'false', // Display posts' title & excerpts
'number_per_cat' => 3, // Number of posts per category
'custom_post_type' => 'articles', // Custom post types
'taxonomy' => 'category', // Taxonomy
'sort_by_category' => 'true', // Sort posts by category
'category_title' => 'true', // Display category titles
'category_link' => 'true', // Display link to categories
'category_ltitle' => 'Read More', // Custom title for links to categories
'auto_excerpt' => 'true', // Build an extract from content automatically
'excerpt_length' => 15 // Make the extract 15 words length
);
// Execute
single_latest_posts( $parameters );
}
?>
</div>
</div>
<?php
/* Include Footer */
get_footer();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment