Guest User

Untitled

a guest
Oct 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?php
  2. public function add_template_vars()
  3. {
  4. if ( isset($this->posts) && count($this->posts) ) {
  5. $post = $this->post instanceof Post ? $this->post : $this->posts[0];
  6. if ( $this->post instanceof Post && count($this->posts) == 1 ) {
  7. $this->set_title( $post->title );
  8. if ( $post->typename == 'entry' ) {
  9. $this->assign( 'next', $post->ascend() );
  10. $this->assign( 'previous', $post->descend() );
  11. }
  12. if ( count($post->tags) ) {
  13. $related = Posts::get(array(
  14. 'vocabulary' => $post->tags->getArrayCopy(),
  15. 'content_type' => $post->content_type,
  16. 'status' => Post::status('published'),
  17. 'not:id' => $post->id,
  18. 'limit' => 5,
  19. 'orderby' => 'Rand()'
  20. ));
  21. $this->assign( 'related_posts', $related );
  22. }
  23. }
  24. }
  25. elseif ( URL::get_matched_rule() == null ) {
  26. $this->set_title('Page Not Found');
  27. }
  28. parent::add_template_vars();
  29. }
  30. ?>
Add Comment
Please, Sign In to add comment