Created
September 20, 2014 15:21
-
-
Save daveis/e87da993ef99fea58d6d to your computer and use it in GitHub Desktop.
Returns the prev/next article title while reading an article in Anchor CMS. Goes in your theme's functions.php file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return next and previous article titles | |
function dg_article_previous_title() { | |
$page = Registry::get('posts_page'); | |
$query = Post::where('created', '<', Registry::prop('article', 'created')) | |
->where('status', '!=', 'draft'); | |
if($query->count()) { | |
$article = $query->sort('created', 'desc')->fetch(); | |
$page = Registry::get('posts_page'); | |
return $article->title; | |
} | |
} | |
function dg_article_next_title() { | |
$page = Registry::get('posts_page'); | |
$query = Post::where('created', '>', Registry::prop('article', 'created')) | |
->where('status', '!=', 'draft'); | |
if($query->count()) { | |
$article = $query->sort('created', 'asc')->fetch(); | |
$page = Registry::get('posts_page'); | |
return $article->title; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code goes in the functions.php file in my Manifesto theme.
This will allow you to use this code in your theme to show article titles for the prev/next pagination.