public
Last active

Example of use of Single Latest Posts embedded into a template file. This one includes parameters not yet made publicly available.

  • Download Gist
slposts_cptTemplate.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<?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();
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.