Readme.rst 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. Related posts
  2. -------------
  3. This plugin adds the ``related_posts`` variable to the article's context.
  4. By default, up to 5 articles are listed. You can customize this value by
  5. defining ``RELATED_POSTS_MAX`` in your settings file::
  6. RELATED_POSTS_MAX = 10
  7. You can then use the ``article.related_posts`` variable in your templates.
  8. For example::
  9. {% if article.related_posts %}
  10. <ul>
  11. {% for related_post in article.related_posts %}
  12. <li><a href="{{ SITEURL }}/{{ related_post.url }}">{{ related_post.title }}</a></li>
  13. {% endfor %}
  14. </ul>
  15. {% endif %}
  16. Your related posts should share a common tag. You can also use ``related_posts:`` in your post's meta data.
  17. The 'related_posts:' meta data works together with your existing slugs::
  18. related_posts: slug1, slug2, slug3, ... slugN
  19. ``N`` represents the ``RELATED_POSTS_MAX``.
  20. Additionally, you can specify::
  21. RELATED_POSTS_SKIP_SAME_CATEGORY = True
  22. in your settings file. With this setting, ``article.related_posts`` will
  23. contain only related posts from categories other than the original article's.